Asv3's Blog

December 11, 2009

difference between window.onload and document.ready

Filed under: javascript — Tags: , , , , — asv3 @ 11:43 am

It’s pretty simple but people tend to forget.

Major bugbeer for javascript developers is non-availability of DOM for javascript execution, if you are including javascript inside <head> tag this is the common situation. window.onload solved this problem. if you callback a function on window.onload that function gets called after page loading completed. Here the problem is javascript execution needs to wait till all CSS and images gets loaded. Hence came the DOMContentLoaded. Most browsers trigger this event when they are ready for javascript execution, this event gets fire before window.onload

all javascript libraries provide hooks to this event,

in jquery

$(document).ready(function() {     
               // put all your jQuery goodness in here. 
            });

in yui 2.x

YAHOO.util.Event.onDOMReady(function() {
    domReady = true;
    alert('Dom is Ready');
});

October 5, 2009

DOM

Filed under: front-end, javascript — Tags: , — asv3 @ 11:44 am

DOM, Document Object Model for XML that extended to be used in HTML. In XML and HTML Document consist hierarchy of nodes with different types of data. DOM allows unprecedented control over web pages. Nodes can be added, removed, replaced and modified easily.

DOM Core was the API developed to handle XML documents, DOM HTML extended DOM Core by adding HTML specific objects and methods. DOM is not JavaScript specific, it is implemented in numerous other languages as well, where as DOM for web implemented using ECMAScript, and makes up to large part of JavaScript.

Idea behind W3C developing DOM Level 1 (1998) was to map structure of a document. Aims of DOM Level 2 was much broader including support for events, range, traversal of document, and support for CSS. Level 1 also extended to support XML namespaces.

Following new modules were introduced in DOM Level 2

DOM Event

DOM Style

DOM Views

DOM Range and Traversal

DOM 3 further extend DOM to introduces methods to Load and Save documents in uniform way, and also methods to validate DOM

DOM, Document Object Model for XML that extended to be used in HTML. In XML and HTML Document consist hierarchy of nodes with different types of data. DOM allows unprecedented control over web pages. Nodes can be added, removed, replaced and modified easily.

DOM Core was the API developed to handle XML documents, DOM HTML extended DOM Core by adding HTML specific objects and methods. DOM is not JavaScript specific, it is implemented in numerous other languages as well, where as DOM for web implemented using ECMAScript, and makes up to large part of JavaScript.
Idea behind W3C developing DOM Level 1 (1998) was to map structure of a document. Aims of DOM Level 2 was much broader including support for events, range, traversal of document, and support for CSS. Level 1 also extended to support XML namespaces.
Following new modules were introduced in DOM Level 2
DOM Event
DOM Style
DOM Views
DOM Range and Traversal
DOM 3 further extend DOM to introduces methods to Load and Save documents in uniform way, and also methods to validate DOM

DOM, Document Object Model for XML that extended to be used in HTML. In XML and HTML Document consist hierarchy of nodes with different types of data. DOM allows unprecedented control over web pages. Nodes can be added, removed, replaced and modified easily.

DOM Core was the API developed to handle XML documents, DOM HTML extended DOM Core by adding HTML specific objects and methods. DOM is not JavaScript specific, it is implemented in numerous other languages as well, where as DOM for web implemented using ECMAScript, and makes up to large part of JavaScript.

Idea behind W3C developing DOM Level 1 (1998) was to map structure of a document. Aims of DOM Level 2 was much broader including support for events, range, traversal of document, and support for CSS. Level 1 also extended to support XML namespaces.

Following new modules were introduced in DOM Level 2

  • DOM Event
  • DOM Style
  • DOM Views
  • DOM Range and Traversal

DOM 3 further extend DOM to introduce methods to Load and Save documents in uniform way, and also methods to validate DOM

Blog at WordPress.com.