繁体   English   中英

在新标签中的iframe中打开链接

[英]Open Links in an iframe in a new tab

我已经将Excel文件转换为.htm文件。 在excel文件中是链接。 我已将.htm文件嵌入我的网站中。这些链接应在新标签页中打开,而不是在iframe中打开。

我怎样才能做到这一点? target =“ _ blank”无效。

<iframe src="website.htm" style="border:none;" width="100%" height="300">
</iframe>

这也行不通:

<script src="https://code.jquery.com/jquery-latest.js"></script>
<iframe src="website.htm" style="border:none;" width="100%" height="300">
</iframe>
<script>
$('iframe a').attr('target', '_blank');
</script>

你可以试试

<iframe src="website.htm" style="border:none;" target="_top" width="100%" height="300">
</iframe>

使用jQuery:

$('iframe a').attr('target', '_blank');

尝试如下:

var linkList = [iframeElement].contentWindow.document.getElementsByTagName("a");
for (var i = 0; i < linkList.length; i++) {
    linkList[i].target = "_blank";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM