<div class="codetitle"> <span><a style="CURSOR: pointer" data="21209" class="copybut" id="copybut21209" onclick="doCopy('code21209')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code21209"> <br> <br> <br> <br><title>简单的事件处理</title> <br><br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <br><meta http-equiv="description" content="this is my page"> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <br><br><!-- <BR><script language="text/javascript" src="hello.html">这个js的外部调用标签不能自结束</script> <BR><link rel="stylesheet" type="text/css" href="./styles.css"> <BR>--> <br><script type="text/javascript"> <BR>function clickD(obj){ <BR>alert(obj.innerHTML); <BR>} <br><br>function mouseD(obj){ <BR>obj.style.color = "#f00"; <BR>//当使用代码来设置样式时,如果css中通过-来表示的,都必须要用驼峰标示font-size -> fontSize <BR>obj.style.fontSize = "16px"; <BR>} <BR>function outD(obj){ <BR>obj.style.color = "#000"; <BR>obj.style.fontSize = "18px"; <BR>} <br><br>//with的用法 <BR>with(document){ <BR>write("dddd<br/>"); <BR>} <BR>document.write("aaaa<br/>"); <BR>document.write("bbbb<br/>"); <BR>document.write("cccc<br/>"); <BR></script> <br> <br><br> <br><div onclick="clickD(this)" style="cursor:pointer;">点击了试一下</div> <br><div onmouseover="mouseD(this)" onmouseout="outD(this)">鼠标移动来试试</div> <br><br> <br> <br> </div> <br>2,浏览器对象的例子:《涉及的是两个浏览器页面之间的传值》 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="12923" class="copybut" id="copybut12923" onclick="doCopy('code12923')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code12923"> <br>BR>"http://www.w3.org/TR/html4/strict.dtd"> <br><br><br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>js01_hello</title> <br><meta name="author" content="Administrator"> <br><script type="text/javascript"> <BR>// setTimeout("endWelcome()",5000); <BR>// function endWelcome() { <BR>// document.getElementById("welcome").style.display = "none"; <BR>// } <BR></script> <br> <br> <br><div id="welcome">欢迎进行我们的网站</div> <br><a href="#" onclick="window.open('test02.html','aaa','width=300,height=300,resizable=0')">test02</a> <br><a href="#" onclick="window.open('test03.html','aaa','width=400,height=400,resizable=0')">test03</a> <br><br> <br><a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">输入你祝福语</a> <br><a href="#" onclick="window.open('bless.html','aaa','width=600,height=300')">选择性别</a> <br><div id="bless"></div> <br> <br> <br> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="90897" class="copybut" id="copybut90897" onclick="doCopy('code90897')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code90897"> <br>BR>"http://www.w3.org/TR/html4/strict.dtd"> <br><br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>js01_hello</title> <br><meta name="author" content="Administrator"> <br><script type="text/javascript"> <BR>function bless() { <BR>//获取输入的祝福语 <BR>var mb = document.getElementById("mb").value; <BR>//获取父类窗口 <BR>var p = window.opener; <BR>//获取父类窗口中的id为bless的div <BR>var pd = p.document.getElementById("bless"); <BR>//设置pd的值 <BR>pd.innerHTML = mb; <BR>//关闭当前窗口 <BR>window.close(); <BR>} <BR></script> <br> <br> <br>输入祝福语:<input type="text" size="40" id="mb"><input type="button" onclick="bless()" value="输入"> <br> <br> <br> </div>