<script language="javascript" type="text/javascript" >
document.writeln("<style type=\"text/css\">body {margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;target:_blank;}");
document.writeln("</style><iframe align=\"center\" marginwidth=\"1\" marginheight=\"1\" ");
document.writeln("src=\"http://www.lio880.com/goods\" ");
document.writeln("frameborder=\"0\" width=\"1003\" scrolling=\"No\" ");
document.writeln("height=\"2410\"></iframe>");
</script>如何点击iframe调用的url中的所有链接都在新窗口中打开?
document.writeln("<style type=\"text/css\">body {margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;target:_blank;}");
document.writeln("</style><iframe align=\"center\" marginwidth=\"1\" marginheight=\"1\" ");
document.writeln("src=\"http://www.lio880.com/goods\" ");
document.writeln("frameborder=\"0\" width=\"1003\" scrolling=\"No\" ");
document.writeln("height=\"2410\"></iframe>");
</script>如何点击iframe调用的url中的所有链接都在新窗口中打开?
你从父页面里需要设置 iframe 里面页面的 a 标记的 target 为 _blank
下面的方法适用于当 iframe 中页面来自相同源(相同域)时:function setTarget(self){
var aLinks, aHref;
aLinks = self.documment.getElementsByTagName('a');
for(var i=0;i<aLinks.length;i++){
if(aHref = aLinks[i].getAttribute('href')){
aLinks[i].setAttribute('target','_blank');
}
}
}document.getElementById('my_iframe').onload = setTarget(this);
对于想嵌入跨域 iframe 页面,这个方法不行
此时,你需要在该页面中自己做处理