• JavaScript
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.

Support

Tested in IE6 , FF, Opera, Chrome and Safari (for Windows).

License

Code falls under the MIT License.

Credits

Related Articles

Fork me on GitHub

No comments yet.

Send your comment

  • RSS
  • LinkedIn
  • Twitter