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.
Asked
Active
Viewed 8,123 times
4
2 Answers
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
-
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
-
thats not possible because accessing the contentWindow when we have a different domain will give security errors. – sushil bharwani Apr 21 '11 at 07:58
-
i am actually willing to set the height of the iframe. And iframe content is on different domain – sushil bharwani Apr 21 '11 at 08:06