I get a script and it have image and link, i want after click on image alert ok and after alert go to a link (href). That’s a cross domain iframe.How is it?
True. Although I ddi test and changed it to div/iframe/etc, and it didn’t work.
I was googling and apparently it won’t work without revamping it. He meant ot target the anchor inside of the iframe. Perhaps he needs to put this jquery inside of the iframe page.
There is no click event for an iframe and you would probably need something like this to do it properly.
You could however absolutely place a link over the top of the iframe and set the destination of the link to the same as that you wanted for the iframe. You could then add an alert to the link.
$(function(){
$(".addv iframe").load(function(){
var iBody = $(".addv iframe").contents().find("body");
var iDiv = iBody.find("a");
alert(iDiv.html())
/*code to change the div content*/
});
});
Normally, when you click on the image opens a new page.Now I want to give a alert before opening a new tab.(I want to open in a new page will show the alert .) How can it be done?
You can’t find anything in an iframe. Its not yours to find. It’s another site.
Think of an iframe as another site. You can’t put code on your page and have it affect someone else’s site.
The only way to can have control over an iframe is if you have access to the iframe’s code and then you can add code inside the iframe that will allow you to communicate with the parent page. (Or if the iframe is on the same domain then some browsers allow limited access.)
You can only do what I have shown and send the user to a link that you know. You can’t send them to a random link in an iframe.