gpt4 book ai didi

javascript - 在 iframe 中打开新窗口链接

转载 作者:行者123 更新时间:2023-11-30 09:09:34 25 4
gpt4 key购买 nike

我在页面上有一个 iframe,并且有一个链接(在同一域中)我想在新的物理窗口中打开。当我使用 target="_blank"时,它只是用新的 iframe 重新加载页面。

我也试过这段 JavaScript/jQuery 代码:

$(document).ready(function() {
$('a[target=_blank]').click(function() {
window.open(this.href);
return false;
})
});

没有成功。

HTML 标签如下所示:

<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>

最佳答案

你可以尝试这样的事情:

$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});

关于javascript - 在 iframe 中打开新窗口链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1457288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com