惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - 狼问苍穹

php图片、文件上传 怎样推广自己的博客 nfs文件系統 重新来过! 网站被挂iframe木马的解决方案 mysql截取函数LOCATE和POSITION PHP公历农历转换(阴历阳历转换)阴历和阳历转换 去掉fck里的图片 js 对FCKeditor 进行是否为空验证 Zend studio 打开 utf-8 出现乱码之解决办法 解决HTML内部元素的Mouse事件干扰(实例,兼容ff,ie) 兼容IE、Firefox的DIV透明 阻止JavaScript事件冒泡传递 date picker plugin - jQuery 用法 Transact-SQL语句总汇(转载) 建一个临时表 php数组总结资料 js获取url参数 smarty date_format 产生乱码??
JavaScript事件监听完整实例
狼问苍穹 · 2009-01-16 · via 博客园 - 狼问苍穹

 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2<html xmlns="http://www.w3.org/1999/xhtml">
 3<head>
 4<title>JavaScript事件监听完整实例(含注释)</title>
 5<meta name="generator" content="editplus" />
 6<meta name="Keywords" content="AddEventHandler,addEventListener,attachEvent,appendChild,getElementsByTagNamem,createElement,createTextNode,IE 与FF兼容性,JavaScript事件,JavaScript监听">
 7<script type="text/javascript">
 8var oEventUtil = new Object();
 9oEventUtil.AddEventHandler = function(oTarget,sEventType,fnHandler)
10{
11//IE和FF的兼容性处理
12 
13//如果是FF
14if(oTarget.addEventListener){
15oTarget.addEventListener(sEventType,fnHandler,false);
16}

17//如果是IE
18else if(oTarget.attachEvent){
19oTarget.attachEvent('on'+sEventType,fnHandler);
20}
 else{
21oTarget['on'+sEventType] = fnHandler;
22}

23}
;
24 
25//定义oT事件函数
26var oT = function()
27{
28var oEvent = arguments[0];
29var oTarget = oEvent.target || oEvent.srcElement;
30alert(oTarget.tagName+'\n'+oTarget.innerHTML+'\n'+oEvent.type);
31}

32 
33//页面加载时制造36个p,每个p里面显示的文字是Line + i
34window.onload = function(){
35for(var i = 0;i<36;i++)
36{
37var oP = document.createElement('p');
38var oText = document.createTextNode('Line'+i);
39oP.appendChild(oText);
40//在文档的第一个div里面添加这些p
41document.getElementsByTagName('div')[0].appendChild(oP);
42}

43 
44//找到所有的p,并添加click的事件监听
45var oPList = document.getElementsByTagName('p');
46for(var i = 0;i<oPList.length;i++)
47{
48oEventUtil.AddEventHandler(oPList[i],'click',oT);
49}

50}

51
</script>
52 
53 
54<style type="text/css">
55*
56{
57margin:0px;
58padding:0px;
59}

60div
61{
62margin:10px auto;
63width:690px;
64border:solid 1px #000;
65min-height:600px;
66padding:20px;
67}

68 
69div p
70{
71padding:4px;
72margin-left:4px;
73margin-top:4px;
74border:solid 1px blue;
75width:100px;
76float:left;
77}

78pre{
79margin:20px 0 0 0;
80}

81a
82{
83text-indent:4em;
84}

85
</style>
86</head>
87<body >
88
89<div>
90</div>
91</body>
92</html>