I want to get the parent domain or url or hostname inside javascript iframe.
I used document.referrer for this, but it only works for the first time. By this I mean that my iframe contains the form, so when the user submits the form, loading the iframe again and the referrer will become my iframe domain.
Now every time my iframes are loaded, I want the parent domain name to be created only as I create the links using this.
Example:
$(".setUrl").each(function(){ var referrer = document.referrer; this.href=referrer+"/abc.html"; });
But this only works for the first time for the reason I mentioned above. So can someone help me overcome this?
Ask me if more clarity is required.
mahesh
source share