km3945
(km3945)
版主
  
版主
UID 46538
精华
0
积分 1320
帖子 1284
金钱 1320 喜悦币
威望 0
人脉 0
阅读权限 100
注册 2004-11-8
状态 离线
|
[推荐阅读] 完了完了....高考失败!
<?php <html> <head> <title>JavaScript and the DOM</title> <script language="JavaScript"> function test() { var myDocument = document; var htmlElement = myDocument.documentElement;
alert("The root element of the page is " + htmlElement.nodeName);
var headElement = htmlElement.getElementsByTagName("head")[0]; if (headElement != null) { alert("We found the head element, named " + headElement.nodeName);
var titleElement = headElement.getElementsByTagName("title")[0]; if (titleElement != null) { if (myDocument.all) { alert("The page title is '" + titleElement.innerHTML + "'"); } else { var titleText = titleElement.firstChild; alert("The page title is '" + titleText.nodeValue + "'"); } }
var bodyElement = headElement.nextSibling; while (bodyElement.nodeName.toLowerCase() != "body") { bodyElement = bodyElement.nextSibling; }
// We found the <body> element...
// Remove all the top-level <img> elements in the body if (bodyElement.hasChildNodes()) { for (i=0; i<bodyElement.childNodes.length; i++) { var currentNode = bodyElement.childNodes[i]; if (currentNode.nodeName.toLowerCase() == "img") { bodyElement.removeChild(currentNode); } } } } } </script> </head> <body> <p>JavaScript and DOM are a perfect match. You can read more in <i>Head Rush Ajax</i>.</p> <img src="http://www.headfirstlabs.com/Images/hraj_cover-150.jpg" /> <input type="button" value="Test me!" onClick="test();" /> </body> </html> ?>
|  学会用下半身来思考! |
|