0

Here is my problem:

I have threes iframes, with some kind of content. I need to "start" them with for example 1 sec interval. But! I can't change content of html file at all (i have content watcher that refreshes page after any change of file) Is there any possibility to delay serving contents of iframes?

Of course something like that: jQuery .ready in a dynamically inserted iframe or that: Load iFrame after page load or anything i could find here doesnt work.

Community
  • 1
  • 1
user1974566
  • 210
  • 2
  • 14

1 Answers1

1

Don't give them an src and use a data attribute instead

<iframe data-src="http://google.com"></iframe>

Then loop over them and set the src based on whatever interval you want

var frameInterval = 1000;
$('iframe').each(function(index){
     var $frame = $(this), src = $frame.data('src');
     setTimeout(function(){
        $frame.attr('src', src);
     }, index * frameInterval );   
});

The comments in question about content watcher are not clear enough to understand what that issue means with regard to this situation

charlietfl
  • 170,828
  • 13
  • 121
  • 150