在iframe中打开新窗口链接 [英] Open in new window link in an iframe

查看:98
本文介绍了在iframe中打开新窗口链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an iframe on a page and there is a link (on the same domain) I would like to open in a new physical window. When I use target="_blank", it just reloads the page in an iframe with the new one.

我还尝试了以下JavaScript/jQuery代码:

I also tried this JavaScript/jQuery code:

$(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;
        });
    });
});

这篇关于在iframe中打开新窗口链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆