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
  • 398,947
  • 96
  • 818
  • 769
sushil bharwani
  • 29,685
  • 30
  • 94
  • 128

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
  • 169,008
  • 28
  • 173
  • 236
  • 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,308
  • 1
  • 22
  • 27