I would expect this:
$('a').setAttribute('target','_blank');
.. for failure (in silence - because jquery usually fails), because if the contents of the iFrame belong to a different domain, there are problems accessing the page in the iFrame from the containing page.
That is: if your own page belongs to domain a (for example, mysite.com) and iframe belongs to domain b (for example someothersite.com), then the security behavior of the web browser is such that using javascript to control the contents of the iFrame will result in an error "Access denied."
If you used jQuery jQuery without jquery, you will see an error. From the parent page something like this:
window.frames["iFrameName"].getElementsByTagName("a")[0].target="_blank"
you will see an error.
Unfortunately, I'm not sure what you can do about it. This is a deliberate thing to stop one website, including another, and change the contents after loading so that it says something else.
One way would be to call a script on your server (i.e. in the same domain) and pass the URL. The script receives the contents of the page you were on and rejects it in your browser, so you will have the contents of your desired web page, but its address is on your site .. for example, if it's php:
http://yourdomain.com/getURL.php?url=http:www.google.com
Beware of authentication issues there though
user2808054
source share