Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-21-2010, 12:08 AM   PM User | #1
jcoc611
New to the CF scene

 
Join Date: Oct 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jcoc611 is an unknown quantity at this point
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..
jcoc611 is offline   Reply With Quote
Old 10-21-2010, 10:27 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,908
Thanks: 10
Thanked 293 Times in 289 Posts
Dormilich is on a distinguished road
and how do you pass it one or more functions to execute without hardcoding it and not eating resources?
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Tags
dom, function, javascript, ready, simple

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:03 AM.


Advertisement
Log in to turn off these ads.