Is there a way to force links in an iframe to open in a new window? The iframe content is on a different domain
I was wondering if there is a way to get links in an iframe to open in a new wind开发者_Python百科ow. The trick is the iframe content is on a different domain, and on that domain the links open in the same page. I tried adding this to the html head
<base target="_blank" />
but it still opens in the iframe. If this is impossible to do on a different domain let me know.
This requires jQuery but should work.
$(document).ready(function()
{
var baseTag= document.createElement('base');
baseTag.target = '_blank';
$("iframe html head").append(baseTag);
});
If it doesn't, then it's quite possibly because you can't access the contents of an iframe through jQuery. Not sure if you can or not.
精彩评论