灯箱 iFrame 问题

发布于 2024-11-28 09:46:04 字数 497 浏览 3 评论 0原文

我有一个加载了灯箱的 iFrame。我遇到的问题是这样的。我希望在单击灯箱弹出窗口中的链接后,父页面重定向到不同的页面。这有道理吗?请帮忙。先感谢您。

我昨天从 yokoloko 收到了这个答案(非常感谢),但我不确定代码的哪些部分必须填写我的信息。有人可以帮忙吗?谢谢。

来自 Yokoloko:

唯一的方法是在父框架中定义一个 javascript 函数,以便在子框架中调用。

例如,如果您使用 jQuery,则在您的父框架中:

function redirectFromFrame(link){
    window.location.href = link;
}

在您的 lightbox 框架中,您应该有类似的内容。

$(function() {
    $('a').click(parent.redirectFromFrame($(this).attr('href')));
});

I have an iFrame that is loaded with a lightbox. The problem I am having is this. I want the parent page to redirect to a different page after a link in the lightbox pop up is clicked. Does this make sense? Please help. Thank you in advance.

I received this answer yesterday from yokoloko (thank you very much) But I am not sure which parts of the code I have to fill in with my information. Can somebody please help? Thanks.

From Yokoloko:

The only way is to define a javascript function in your parent frame to be called in your child frame.

eg in your parent frame if your using jQuery :

function redirectFromFrame(link){
    window.location.href = link;
}

and in your lighbox frame you should have something like this.

$(function() {
    $('a').click(parent.redirectFromFrame($(this).attr('href')));
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法言说的痛 2024-12-05 09:46:04

我只想使用这样的东西(并且此代码位于您的 iframe 中)

$(function() {
    $('a').click(function() {
        window.parent.location.href=$(this).attr('href');
    });
});

$('a') 指的是您希望重定向发生的 iframe 中的 a 标记

I would just use something like this (and this code goes within your iframe)

$(function() {
    $('a').click(function() {
        window.parent.location.href=$(this).attr('href');
    });
});

the $('a') refers to the a tag within your iframe that you want the redirection to take place on

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文