Thursday, April 4, 2013

Javascript Methods on Document Object


The Document object represents the entire HTML document and can be used to access all elements in a page.

Document Object Collections
anchors[] Returns a reference to all Anchor objects in the document
forms[] Returns a reference to all Form objects in the document
images[] Returns a reference to all Image objects in the document
links[] Returns a reference to all Area and Link objects in the document

Document Object Properties
Body Gives direct access to the <body> element
Cookie Sets or returns all cookies associated with the current document
Domain Returns the domain name for the current document
lastModified Returns the date and time a document was last modified
Referrer Returns the URL of the document that loaded the current document
Title Returns the title of the current document
URL Returns the URL of the current document

Document Object Methods
close() Closes an output stream opened with the document.open() method
getElementById() Returns a reference to the first object with the specified id
getElementsByName() Returns a collection of objects with the specified name
getElementsByTagName() Returns a collection of objects with the specified tagname
open() Opens a stream to collect the output from any document.write() or document.writeln()
write() Writes HTML expressions or JavaScript code to a document
writeln() Identical to the write(), with the addition of writing a new line character after expression

No comments:

Post a Comment