'Equivalent for 'window.location.ancestorOrigins' in FF and IE
Following is Google Chrome version for getting parent window's URL from iFrame.
window.location.ancestorOrigins;
I'm looking for equivalent of above statement for FireFox and IE. Is it possible to achieve it.
Tried with document.referrer also giving the iFrame Url only.
Solution 1:[1]
Unfortunately, FireFox and IE do not have an equivalent to ancestorOrigins.
The best you can do with regards to getting the parent URL is document.referrer and unfortunately if you are dealing with iframes, this means you may not be able to get to the outside page and get the true URL of the webpage.
Solution 2:[2]
I found this alternative solution. This works for me...
var url = window.location != window.parent.location ?
document.referrer :
document.location.href;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Terence Wight |
| Solution 2 | Hp Sharma |
