www.webdeveloper.com
Results 1 to 4 of 4

Thread: DOMReady, onclick functions?

  1. #1
    Join Date
    Aug 2008
    Location
    NYC
    Posts
    76

    DOMReady, onclick functions?

    Hello, I was wondering if there are any DomReady event functions and onclick functions. I was doing some reading and found that onclick sometimes does not work in different browsers and can cause bubbling. I would go to a framework (preferably Mootools), but Im trying to avoid it.

    I would rather have some function that runs the function when the dom is ready. As Im sure all of us are sick of putting window.onload = function() etc... The onclick I can see being harder to find, but the DOM Ready Event has to exist out there without using a framework, right?

    Let me know, thanks!

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    just put your tag at the end of the body instead of the head.
    when the code in the script fires, your document is ready.

    you can even just place a function call down there, activating script you defined in the head or wherever:
    Code:
    <script>if(window.myReady){ window.myReady();}</script>
    </body></html>
    tiny, simple, and 120&#37; cross browser compatible.

    for a convoluted example that can run from the head: http://www.agileapproach.com/blog-en...ready-function
    Last edited by rnd me; 04-06-2011 at 10:55 PM.

  3. #3
    Join Date
    Aug 2008
    Location
    NYC
    Posts
    76
    What is myReady(); ?

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by mikewgd View Post
    What is myReady(); ?
    myReady is a function you define, perhaps in code that's loaded from the <head> tag. In place of a normal .ready() call, you name a function, any function, myReady. when the document is ready, myReady() will be fired.

    Code:
    function myReady(){
     alert("tags are ready, but images might still be loading");
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles