Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: DOM Ready

  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DOM Ready

    This is my "DOM Ready" function, any suggestions, I just tested it in IE 8, Chrome, and Opera. Seems to work 100%. Besides, it's pretty small compared to other similar functions I've seen.
    Code:
    function domReady(){
    
    if(document.body){
    //Execute something
    } else {
    setTimeout("domReady()",10);
    }
    }; domReady();
    The function is pretty simple, it loops each 10ms checking for document.body. If it is defined then it executes something, else it keeps looping.

    EDIT: I should'v posted this in the JavaScript snippets section....but...lol...
    Last edited by jcoc611; 10-21-2010 at 12:12 AM.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,389
    Thanks
    13
    Thanked 353 Times in 349 Posts
    and how do you pass it one or more functions to execute without hardcoding it and not eating resources?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •