wzhu
(wzhu)
版主
  
C[A-Z]O
UID 68040
精华
0
积分 47793
帖子 1568
金钱 47770 喜悦币
威望 0
人脉 23
阅读权限 100
注册 2006-1-14 来自 湖北荆州>陕西西安>辽宁 ...
状态 离线
|
[推荐阅读] php命令行执行方式
QUOTE: 原帖由 dongyue91 于 2007-6-12 08:13 AM 发表
wzhu
你的方法我早就试过了 不过还是谢谢你
它返回的是空值 怪了,在我及其上就好的
你看看代码是否跟我说的一样
<html>
<head>
<title>JavaScript and the DOM</title>
<script language="JavaScript">
function test() {
// These first two lines get the DOM tree for the current Web page,
// and then the <html> element for that DOM tree
var myDocument = document;
var htmlElement = myDocument.documentElement;
// What's the name of the <html> element? "html"
alert("The root element of the page is " + htmlElement.nodeName);
// Look for the <head> element
var headElement = htmlElement.getElementsByTagName("head")[0];
if (headElement != null) {
alert("We found the head element, named " + headElement.nodeName);
// Print out the title of the page
var titleElement = headElement.getElementsByTagName("title")[0];
if (titleElement != null) {
// The text will be the first child node of the <title> element
var titleText = titleElement.text;
// We can get the text of the text node with nodeValue
alert("The page title is '" + titleText + "'");
}
// After <head> is <body>
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;
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>
附件: 您所在的用户组无法下载或查看附件
|  <?wzhu
wzhu.print("http://www.cncmm.com");
?> |
|