The following are examples of Document Objects.
Understanding Document Objects
The document object is an object that is created by the browser for each new HTML page (document) that is viewed. By doing this, JavaScript gives you access to a number of properties and methods that can affect the document in various ways. We have been using the write() method of the document object for quite some time now in these modules. This method allows you to write a string of text into an HTML document.
Document Properties in Action
The following are going to show you different document properties you can use in JavaScript directly in your document. First I'll show you a "last modified". How this works is simply to have the JavaScript return that last modification date of the document. It is written as document.lastModified and placed into a document.write line.
See How Often I Update My Site!
In Internet Explorer this will be shown as Month/Date/Year and Military time. XX/XX/XXXX XX:XX:XX
In Netscape this will be shown as Day, Month Date, Year and Military time. XXXXXXXX, XXXXX XX, XXXX XX:XX:XX
You can also have JavaScript actually tell the view what hexidecimal colors you have chosen for your links, whether they link within your document or to another site. Using the linkColor, alinkColor and vlinkColor, you can have it return on the page to show the codes used for all to see.
The background color of this particular document is actually set in the CSS that I have attached to this document. The CSS is an external but lets try to see if I can show you the background color anyway.
I thinks it's a nice color, don't you?
But say you don't and would like to see something different. Click the button below to go to a new page to see it working!
I'm a joker at heart and love to help others to go insane. Don't believe me? Click on the button below to see!
Last but not least we will demostrate the open/close method. This method allows you to open a new document and create its contents entirely with document.write() or document.writeln(). When the open method is called, the browser looks for these statements so that it can write the new page. Once the write() and/or writeln() statements are completed, you need to use the document.close() to finish the new page.
Enter your favorite Drivers name in the box below and then click the button to see a the drivers page!