DOMReady JavaScript object (Cross Browser)
The DOMReady is a JavaScript object, waiting to perform the specified code to the DOM is ready. The object controls internally how to deal with different browsers.
How it works?
With the add() method lets you add features to be executed if the DOM is loaded.
DOMReady.add(function () {
alert('DOM is ready!');
});
Or give them arguments to the callback function:
was param1 = 'hello',
param2 = 1234;
DOMReady.add(
function (arg1, arg2) {
// arg1 = 'hello' and arg2 = 1234
},
[param1, param2]
);
Error callback
DOMReady.setOnError(function (err) {
alert(err);
});
API
- DOMReady.add( fn, [args] )
- DOMReady.setOnError( fn )
Download
You can download the latest version of Github.
Version 1.0: domready.js | domready.zipVersion 0.3: minor adjustments domready.js | domready.zipVersion 0.2: errors are collected and it is possible to add an error Handler. domread-0.2.jsVersion 0.1: domready-0.1.js
Support
Tested in IE6 , FF, Opera, Chrome and Safari (for Windows).
License
Code falls under the MIT License.
Credits
- IEContentLoaded van Diego Perini
- IEContentLoaded: Yet another DOMContentLoaded van Dion Almaer
Related Articles
No comments yet.


















