Is there a way to use jQuery to get an iframe to load on a click, i want this as is the iframe is hidden in a div that is not viewable until clicked, so the heavy majority of users will not be viewing the iframe, and i dont want the load time to be affected by the iframe.
This is one of the few things i’ve tried, the iframe does not load:
$(function() {
var emba=1;
var embget = 1;
$(".custemba").click(function(event) {
event.preventDefault(event);
if(emba == 1) {
emba = 2;
$('.custemb').slideDown();
if(embget == 2) {
$('.appendi').append('<iframe src="/player_i.php?aid=12" height="170px" width="100%" scrolling="no" frameborder="0"></iframe>');
embget = 2;
}
}
else if(emba == 2) {
emba = 1;
$('.custemb').slideUp();
}
});
});
Looks like
should be
And you don’t need that extra event in
Here’s a simplified version: