<Html> <title> learn DOM </title> <a id = "wen"> text </a> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <script> /* // attributes of the document in the window // you can set or query all cookies related to the current document. Document. write (document. cookie); // The domain attribute returns the server domain name for downloading the current document. Document. write (document. domain); // localhost // The lastModified attribute returns the Last modified Date and time of the document. Document. write (document. lastModified); // The title attribute returns the title of the current document (text in the HTML title element ). Document. write (document. title); // learn DOM // The URL attribute to return the URL document of the current document. write (document. URL); // http: // localhost/js/dom/04.html // The document method in the window // getElementById () returns a reference to the first object with the specified ID. Var x = document. getElementById ('wen'); alert (x. innerHTML); // text // The getElementsByName () method returns a set of objects with the specified name. var x = document. getElementsByName ("myinput"); alert (x. length); // 4 // The getElementsByTagName () method returns a set of objects with the specified tag name var x = document. getElementsByTagName ('input'); alert (x. length); // 4 // The open () method can open a new document and erase the content of the current document. // The close () method can close an output stream opened by the document. open Method and display the selected data. Var newDoc = document. open ("text/html", "replace"); var txt = "