<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> <br>br> <br>BR> <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> </div> <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> <div class="codetitle"> <div id="bless"></div> <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>