从 iframe 操作重定向父窗口 [英] Redirect parent window from an iframe action

查看:25
本文介绍了从 iframe 操作重定向父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用什么 JavaScript 从 iframe 重定向父窗口?

What JavaScript do I need to use to redirect a parent window from an iframe?

我希望他们点击一个超链接,使用 JavaScript 或任何其他方法,将父窗口重定向到一个新的 URL.

I want them to click a hyperlink which, using JavaScript or any other method, would redirect the parent window to a new URL.

推荐答案

window.top.location.href = "http://www.example.com"; 

将重定向最顶层的父 iframe.

Will redirect the top most parent Iframe.

window.parent.location.href = "http://www.example.com"; 

将重定向父 iframe.

Will redirect the parent iframe.

这篇关于从 iframe 操作重定向父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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