I have a script that write a iframe into the page.
I want to target a link inside this iframe to have a function.
The problem is:
after the iframe has been written I use this code:
$('#iframe_pin').load(function () {
$(this).contents().find('a.close').click(function (event) {
event.preventDefault();
$('.loaded').fadeOut(fade_time).remove();
})
})
and it doesn’t work.
But if I put an alert after the load function, like this:
$('#iframe_pin').load(function () {alert('bla bla');
$(this).contents().find('a.close').click(function (event) {
event.preventDefault();
$('.loaded').fadeOut(fade_time).remove();
})
})
it works!
Of course I cannot keep the alert in the code 🙂
Can anyone help me?
from comments you have something like:
so, all you need to do is: