Iframe source url

How to get url of parent iframe using jQuery or javascript?

+1
source share
2 answers

Just include the url when opening the iframe.

<iframe src="http://foo.bar/iframe.html?iframeparentwindowurl=http://cheese.tv/parrot.html"> </iframe> 
+4
source

For a script running in an iframe, use parent.location.href , although an iframe served from another domain to its parent page will not be able to access it.

If you are in different domains, there are several alternative methods that should work for you. In particular, using window.name to transfer data or stack an iframe inside iframes. Both etc. Listed in this slide show . Window.name is mentioned on slide 31. Especially check slide 34 onwards for the iframe stacking method, which will allow bi-directional communication between different source frames.

+3
source

Source: https://habr.com/ru/post/1379074/


All Articles