4

My iframe is having a url with a hash value when i do iframe.src it just gives me the url without the hash appended to it from the other domain. Can i read the entire url with the hash.

skaffman
  • 390,936
  • 96
  • 800
  • 764
sushil bharwani
  • 28,837
  • 30
  • 92
  • 126

2 Answers2

2

Not likely due to security constraints - I am surprised you can even get the URL

Can you show the code?

Sounds like a duplicate of How to get iframe contentWindow height in cross domain

Community
  • 1
  • 1
mplungjan
  • 155,085
  • 27
  • 166
  • 222
  • i am reading the url from the same domain. So its giving me the url. Only thing that i am doing is appending hash to the url from the other domain. The reading is still happening at same domain. – sushil bharwani Apr 21 '11 at 07:54
  • I think he just means the other URL, i.e. the URL of the iframe. – bart Apr 21 '11 at 11:44
  • @Bart "And iframe content is on different domain " – mplungjan Apr 21 '11 at 13:27
  • Oh, yes, I see now, a comment under another answer. The browser only allows you access to the contents of the iframe if it's on the same domain. – bart Apr 22 '11 at 12:14
2
var contentWnd = $('iframe').attr('contentWindow');
var hash = contentWnd.window.location.hash;

Adaptation of this answer: Get url from iframe and update hash in browser url

Community
  • 1
  • 1
Calum
  • 5,098
  • 1
  • 21
  • 27