如何从Iframe获取父窗口URL? [英] How to get the parent window URL from Iframe?

查看:681
本文介绍了如何从Iframe获取父窗口URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个安全问题。但HTML5中有什么办法吗?因为我看到下面的代码在推文框中打开一个父母URL的窗口

I know it's a security issue. But is there any way in HTML5. Cause I seen the below code opens a window with the parents URL in tweet box

<iframe src="https://platform.twitter.com/widgets/tweet_button.html"
        style="border: 0; width:130px; height:20px;"></iframe>


推荐答案

在iframe中尝试此操作。它将提醒父窗口的位置URL。

Try this inside the iframe. It will alert the parent window's location URL.

alert(document.referrer);

这篇关于如何从Iframe获取父窗口URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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