Difference between Window objects and Document objects
Window objects : It's the top of the hierarchy in document object model and outermost element in object hierarchy.While accessing contents in document, the window object is created.
It can be accessed by window.
Document objects : Each HTML document that gets loaded into a window becomes a document object. The document contains the contents of the page. With this we can add dynamic contents to the page.
It can be accessed by window.document or document.
Both object have individual properties and methods:
Document Property:
activeElement: returns currently active elements.
body: content in body
anchors: elements in attribute
baseURL: string of baseURL in docu
cookie: returns cookie
charSet: string of docu character encoding
defaultView: returns window object
designMode: set documents as editable
domain: domain name
doctype:return docu type
embeds: return embeded elements
URL: provide complete URL
Like this list goes on..
Documents method:
addEventListener(): attach event handler in specified element
Documents method:
addEventListener(): attach event handler in specified element
adoptNode(); adopt a node and return a node object
close(): close output stream
getElementById():return object of given ID
getElementByTagName(): returns elements with specified tag names
getElementByTagName(): returns elements with specified tag names
write(): used to write code in content.
Window Property:
It'll be understandable by name itself like Name,innerHeight,innerWidth,Length,closed,crypto,outerHeight, outerWidth,Toolbar, Screen.
Window methods:
It'll be understandable by name itself like Name,innerHeight,innerWidth,Length,closed,crypto,outerHeight, outerWidth,Toolbar, Screen.
Window methods:
alert(),close(),open(),
scrollBy(),scrollTo(),resizeBy(),resizeTo(),prompt(),moveBy(),moveTo() and so on.