Reputation: 2651
I know there is many of possiblites when it comes to check if an iFrame content has been loaded. Although, is there anyway to limit it?
Example, if I have an iframe, and I need to check if everything has loaded, I can use the load() function. Although, if I click a NEW link inside the iframe, it will run the load() function again.
What I wish to know, is there any way to do, so jquery only checks the FIRST time the iFrame content has been loaded?
I have tried everything, nothing works.
Upvotes: 11
Views: 21073
Reputation: 78687
Use jquery .one, it does the unbind work for you.
$('#iframe').one('load', function() {
});
Example fiddle.
Upvotes: 30
Reputation: 2924
You can unset the load callback again once it gets called.
$('#iframe').load(function() {
// do things which are awesome
$('#iframe').unbind('load');
});
Upvotes: 8