Andreas Wik
Andreas Wik

Reputation: 99

Javascript in iFrame document - how to fetch the browser address bar location?

I am encouraging people to embed my website on their own using an iFrame. What I need to do is to let the Javascript on my page find out their domain. So if they embed my page on http://yahoo.com then I need to be able to fetch that address.

How to?

I tried various things such as parent.window.location, window.location etc. But all I get is the address to my page in the iFrame.

Upvotes: 1

Views: 562

Answers (2)

SHANK
SHANK

Reputation: 2968

try this:

window.opener.document.location

or

window.parent.document.location

Upvotes: 1

sv_in
sv_in

Reputation: 14049

window.parent.document.location would give you the url

Upvotes: 2

Related Questions