<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>新建網頁</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="布爾教育 http://www.itbool.com" /> </head> <body> <form action="m9.php" onsubmit="return t1()"> <p><input type="text" /></p> <p><input type="text" /></p> <p><input type="submit" value="提交"/></p> </form> </body> <script> // 注意在onsubmit提交觸發時,有點特殊 function t1 () { // body... alert("請填寫完整"); return false; } </script> </html> /******************************** *行爲ie結構相分離********/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>新建網頁</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="布爾教育 http://www.itbool.com" /> <style> #div{ width: 200px; height: 200px; } </style> </head> <body> <p>行爲,結構相分離</p> <div> <ul> <li>好</li> </ul> </div> </body> <script> // 行爲,結構相分離 document.getElementsByTagName('div')[0].onclick=function () { this.style.border="1px solid blue"; // body... } </script> </html>