Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
What is the JQuery EXACT equivalent of "onload" event?
Old 01-21-2009, 09:24 AM What is the JQuery EXACT equivalent of "onload" event?
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
I know that generally speaking the better method with JQuery is to use the "ready" function which goes to work as soon as the DOM is in place and doesn't wait around for image downloads.

But what if I DID want to wait until all images were downloaded before manipulating the page?

Instead of this:

$(document).ready(function(){
$('#somediv').html('<p>Some cool comment</p>');
});


What should I be using?
TWD is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-21-2009, 09:53 AM Re: What is the JQuery EXACT equivalent of "onload" event?
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
$(document).load(); ?
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-21-2009, 10:27 AM Re: What is the JQuery EXACT equivalent of "onload" event?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
maybe the above works also, but I've always done:
Code:
$(window).load(function() {
//code will wait for all the images to load before executing
//these load events can exist multiple times, unlike an onload event
});
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-21-2009, 09:07 PM Re: What is the JQuery EXACT equivalent of "onload" event?
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
maybe the above works also, but I've always done:
Code:
$(window).load(function() {
//code will wait for all the images to load before executing
//these load events can exist multiple times, unlike an onload event
});

This works ok when I try it with a simple line of text inside the anonymous function eg.

$(window).load(function(){
$('#somediv').html('<p>Testing</p>');
});

Actually what I`m trying to do though is to get Jquery to run a Flash movie AFTER the images have been loaded. When I just hard code the flash movie the animation seems a bit jerky and I was wondering if the image downloads might be conflicting with it.

So just for curiosity I tried:

$(window).load(function(){
$('#flash_header').html('

<object type="application/x-shockwave-flash"
width="960" height="157" data="/flash/someflashmovie.swf">
<param name="movie"
value="/flash/someflashmovie.swf"></param>
<param name="wmode" value="transparent"></param></object>

');

});

It didn't work. The Javascript error console says "unterminated string literal" but I cant see why.
TWD is offline
Reply With Quote
View Public Profile
 
Old 01-22-2009, 06:47 AM Re: What is the JQuery EXACT equivalent of "onload" event?
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Then I suggest you download SWFObject as well.
It's a JavaScript library which simplifies adding Flash to your page.
You could just call that function in the jQuery load function.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 08-20-2009, 12:48 PM Re: What is the JQuery EXACT equivalent of "onload" event?
Junior Talker

Posts: 1
Name: Will Peavy
Location: Florida
Trades: 0
Quote:
Originally Posted by TWD View Post
It didn't work. The Javascript error console says "unterminated string literal" but I cant see why.
Try removing the line-breaks in the HTML you're inserting.
willpeavy is offline
Reply With Quote
View Public Profile Visit willpeavy's homepage!
 
Reply     « Reply to What is the JQuery EXACT equivalent of "onload" event?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47104 seconds with 12 queries