灯箱 iFrame 问题
我有一个加载了灯箱的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只想使用这样的东西(并且此代码位于您的 iframe 中)
$('a')
指的是您希望重定向发生的 iframe 中的 a 标记I would just use something like this (and this code goes within your iframe)
the
$('a')
refers to the a tag within your iframe that you want the redirection to take place on