7

I know it's a security issue. But is there any way in HTML5. Cause I seen the below code opens a window with the parents URL in tweet box

<iframe src="https://platform.twitter.com/widgets/tweet_button.html"
        style="border: 0; width:130px; height:20px;"></iframe>
user2736812
  • 1,211
  • 4
  • 12
  • 15

2 Answers2

16

Try this inside the iframe. It will alert the parent window's location URL.

alert(document.referrer);
SajithNair
  • 3,831
  • 1
  • 16
  • 23
  • 9
    After doing some `url` navigation inside the `iframe`, `document.referrer` value is not returning `parent window URL`, its returning the `current navigation` we have inside the `iframe`. Is there a way to overcome this scenario? – Dipak Nov 28 '16 at 06:19
2

Give this JavaScript a go

var referrer = document.referrer;
console.log(referrer);

Hopefully it works for your purpose. More info on document.referer here if you want to know more:

https://developer.mozilla.org/en-US/docs/Web/API/document.referrer

Pete
  • 867
  • 1
  • 6
  • 13