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

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - 狼问苍穹

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>