标签:javascript-------------dom操作(一)
JavaScript-------------Dom操作(一)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <!--背景颜色为白色,字体颜色为绿色,链接颜色为红色,未被浏览过的连接颜色为#ffff00--> <body bgcolor="white" text="green" link="red" alink="#ffff00"> <h1 align="center">Test Document</h1> <hr> <!-- 该标签同时具有href、Area(文本)--> <a href="#">Sample link</a> <!-- 该标签同时都没有href、Area(文本)--> <a name="anchor1"></a> <a name="anchor2" href="#a">Sample link2</a> <form name="form1"></form> <form name="form2"></form> <hr> <script> window.document.write("<h1 align=‘center‘> Document Object Properties</h1><br>"); window.document.write("<h2>Basic Page Properties</h2>"); window.document.write("Location = "+window.document.location+"<br>"); window.document.write("URL = " + window.document.URL + "<br>"); window.document.write("Document Title = " + window.document.title + "<br>"); window.document.write("Document Last Modification Date = " + window.document.lastModified+"<br>"); window.document.write("<h2>Page Color</h2>"); window.document.write("Background Color = " + window.document.bgColor + "<br>"); window.document.write("Text Color = " + window.document.fgColor + "<br>"); window.document.write("Link Color = "+window.document.linkColor + "<br>"); window.document.write("ActiveLink Color = "+window.document.alinkColor + "<br>"); window.document.write("Visited Link Color = "+window.document.vlinkColor + "<br>"); if (window.document.links.length > 0){ window.document.write("<h2>Links</h2>"); window.document.write("# Links = "+window.document.links.length + "<br>"); for(var i=0;i<window.document.links.length;i++){ window.document.write("Links[" + i + "]=" +window.document.links[i] + "<br>"); } } /*只输出那些同时具有href和area值的标签*/ window.document.write(""+window.document.links.length); if(window.document.anchors.length > 0){ window.document.write("<h2>Anchors</h2>"); window.document.write("# Anchors = " + window.document.anchors.length + "<br>"); for(var i =0;i<window.document.anchors.length;i++){ window.document.write("Anchors[" + i +"]=" + window.document.anchors[i] + "<br>"); } } if(window.document.forms.length > 0){ window.document.write("<h2>Forms></h2>"); window.document.write("# Forms = " + window.document.forms.length + "<br>"); for(var i = 0; i <window.document.forms.length;i++){ window.document.write("Form[ " + i + "] = "+window.document.forms[i].name + "<br>"); } } </script> </body> </html>
本文出自 “@coder” 博客,请务必保留此出处http://smallcoder.blog.51cto.com/11941149/1856035
JavaScript-------------Dom操作(一)
标签:javascript-------------dom操作(一)
原文地址:http://smallcoder.blog.51cto.com/11941149/1856035