Jabooh web design Telford, Shropshire

Website design and IT solutions

Jabooh.com web design and IT solutions based in Telford Shropshire serving the Midlands and the whole of the UK.

Call us: 07530 259 181 or email us via the contact form for a free quote today.

Technologies we use: php, mysql, vb, google maps, database, content managed, cms, and javascript. Services we offer: search engine optimisation, hosting, website design, cheap websites.

Get in touch today if you are looking for an affordable website to help establish or improve your companies web presence.

This page describes how to call a function or JavaScript code when the page/DOM is ready without using jquery or any other JavaScript library/framework.

After searching the web for a good example of doing this, most roads lead to jQuery, however I really needed to find a way without using an external library. Simply because it would have been an unnecessary overhead as no other items called for the use of jQuery on the page.

Here is the code:

 //add event
 if (window.addEventListener){
  window.addEventListener("load", function(){ alert('DOM Ready!!'); }, false);
 }else if
  (window.attachEvent){
  window.attachEvent("onload", alert('DOM Ready!!'););
 }else{
window.onload = alert('DOM Ready!!');
 }

You can add JavaScript code directly to the above code or specify a function to call when the DOM has loaded fully. To see a full example of using the JavaScript DOM ready function please view the following link on pastebin.com

To use the jQuery DOM ready function use: $(document).ready(function() { alert('DOM Ready!!') }); for more information see the jQuery website.

Are you looking for a website? Please get in touch

This page was last updated: 17 May 2011