开发者

document.referrer of iframe parent

I have a page - page1.html, which contains iframe with url(src) iframepage.html. When I click on the link from iframepage, I go to some other website - page2.html. If i call document.referrer on the page2.html, I have the iframepage url. This is correct according to document.reffer definition - which is the document, that opened current document, but:

Is there any way to get as document.referrer on page2.html the page1.html?

Fro开发者_如何学Cm page2.html I have to know from which browser url was page2.html opened.

Thank you


In page2.html you can check window.parent.location.href in javascript to return the URL of the parent containing the <iframe>.


In Google Chrome, you would be able to use:

window.location.ancestorOrigins;

This will return the parent window URL for the page outside of the iframes.

However, this is not possible in Firefox or IE unfortunately, the best you can get is document.referrer in these.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜