[英]How to get the parent window URL from Iframe?
I know it's a security issue. 我知道这是一个安全问题。 But is there any way in HTML5. 但HTML5中有什么办法吗? Cause I seen the below code opens a window with the parents URL in tweet box 因为我看到下面的代码在tweet框中打开一个带有父URL的窗口
<iframe src="https://platform.twitter.com/widgets/tweet_button.html"
style="border: 0; width:130px; height:20px;"></iframe>
Try this inside the iframe. 在iframe中尝试这个。 It will alert the parent window's location URL. 它将提醒父窗口的位置URL。
alert(document.referrer);
Give this JavaScript a go 给这个JavaScript一个
var referrer = document.referrer;
console.log(referrer);
Hopefully it works for your purpose. 希望它适合您的目的。 More info on document.referer here if you want to know more: 有关document.referer的更多信息,如果您想了解更多信息:
https://developer.mozilla.org/en-US/docs/Web/API/document.referrer https://developer.mozilla.org/en-US/docs/Web/API/document.referrer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.