I want to get the parent domain or url or hostname inside iframe javascript.
I have used document.referrer for that, but it only works the first time. By this I mean that my iframe contains the form so when the user submits the form the iframe loads again and the referrer will become the my iframe’s domain.
Now each time my iframe loads I want the parent domain name only as I am creating the links using that.
Example:
$(".setUrl").each(function(){
var referrer = document.referrer;
this.href=referrer+"/abc.html";
});
But this only works the first time because of the reason I mentioned above. So can somebody help me overcome this?
Ask me in case if more clarity required.
You can do one thing for this:
You can use any logic…
e.g: