Monday, July 28, 2014

window and document

Information from
Window object represents an open window in a browser. each frame (iframe) has one additional window. It has properties and methods. Usually the global scope in javascript means this window object.

When an HTML document is loaded into a web browser, it becomes a document object. The document object is the root node of the HTML document and the "owner" of all other nodes: (element nodes, text nodes, attribute nodes, and comment nodes). Document object inherits all properties and methods from the Node object, so many properties and methods make no sense on document object.

The contentWindow property returns the Window object generated by an iframe element.

contentDocument = contentWindow.document
From the DOM iframe element, scripts can get access to the window object of the included HTML page via the contentWindow property. The contentDocument property refers to the document element inside the iframe (this is equivalent to contentWindow.document), but is not supported by Internet Explorer versions before IE8.

The createDocumentFragment() method is usefull when you want to extract parts of your document, change, add, or delete, some of the content, and insert it back to your document.

Information from discussion
Window is the main JavaScript object root, also can be treated as the root of the document object model. You can access it as window in most of the cases (in the browser);

window.screen is a small information object about physical screen dimension.

window.document or just document is the main object of the visible document object model/DOM.

No comments:

Post a Comment