If you only have one iframe, just set the iframe's src
attribute in the .show()
callback function.
<script type="text/javascript">//<![CDATA[
jQuery(window).load(function($){
setTimeout(function(){
$('.hidden_div').show(function(){
$(this).find('iframe').attr('src', 'https://example.com/');
});
}, 5000);
});//]]>
</script>
If you need more dynamic code, remove the src
attribute of the iframe, and add a new attribute with the url like so
<iframe data-src="https://example.com/"></iframe>
And then clone the data attribute to the src attribute like so:
<script type="text/javascript">//<![CDATA[
jQuery(window).load(function($){
setTimeout(function(){
$('.hidden_div').show(function(){
var src = $(this).find('iframe').attr('data-src');
$(this).find('iframe').attr('src', src);
});
}, 5000);
});//]]>
</script>
If you want to use the original code you have, this will work. The problem is you don't have the $
jQuery alias defined yet.
<script type="text/javascript">//<![CDATA[
jQuery(window).load(function($){
setTimeout(function(){
$(".hidden_div").show(function(){
$(this).find("iframe").prop("src", function(){
return $(this).data("src");
});
});
}, 5000);
});//]]>
</script>
.prop
function, I'm not sure that's valid. Why don't you just have the.hidden_div
show after 5 seconds instead of trying to mess the with iframe's src attribute?$
alias to be defined