javascript calling info
I c开发者_StackOverflowreated a facebook fanpage(iframe) application. I would like to fetch the addressbar information from the fanpage iframe.
I tried alert(top.location.href) from fanpage iframe application, but nothing happens.
If i use top.location.href = www.google.com then it works, but if I just use alert(top.location.href) nothing happens.
This must mean that it is writable but not readable.
How can I solve this?
This is because of the Same Origin Policy. You can't access data from a different domain. Trying to do so throws a "Permission Denied" error. If top.location.host != location.host
, you cannot access its data.
It's a problem with Chrome, according to CodeGuru.
Running this locally wont work either, have you tried on a webserver?
精彩评论