Monday, June 16, 2008
Document Object in JavaScript
Document Objects in JavaScript
To write in document
document.write("Hello World!");
document.writeln("Hello World!");
The title of the document
var title = document.title;
The URL of this document
var url = document.URL;
The referrer of this document
var referrer = document.referrer;
The domain name for this document
var domain = document.domain;
To get element object by ID
var obj = document.getElementById("id_name");
To get element object by Name
var obj = document.getElementsByName("tag_name");
To get element object by TagName
var obj = document.getElementsByTagName("tag_name");
Number of anchors in this document
var cnt_anchor = document.anchors.length;
Number of Form in this document
var cnt_frm = document.forms.length;
Number of images in this document
var cnt_img = document.images.length;
The cookie property sets or returns all cookies associated with the current document.
var cookie = document.cookie;
The lastModified property returns the date and time the document was last modified.
var lastmodified = document.lastModified;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment