Please note that window.document is similar as document.
By the methods of the document object, a document can be accessed and changes can be made. Here are some of the most important methods of document:
|write("string")||This method writes the given string on the document.|
|writeln("string")||This method writes the given string on the document with newline character at the end.|
|getElementById()||This method returns the element having the provided id value.|
|getElementsByName()||This method returns all the elements having the given name value.|
|getElementsByTagName()||This method returns all the elements having the given tag name.|
|getElementsByClassName()||This method returns all the elements having the given class name.|
Here is an example to let you understand the document object with these following parameters included:
In this example, the value of the input text by the user will be derived and document.form1.value is being used to get the value of the name field. All the terms and parameters are explained above.
Here is the example of a document object that prints name with a welcome message: