Side navigation
#4288 closed bug (invalid)
Opened March 04, 2009 05:40AM UTC
Closed October 13, 2009 12:43AM UTC
Last modified March 15, 2012 02:02PM UTC
jQuery not working inside Facebook iframe-based application
Reported by: | rafidka | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | unfiled | Version: | |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Dear Sir/Madam,
I am developing a Facebook application using iframe. I want to use jQuery but I get the following error in IE (I do not get this problem in FF and Chrome):
"Access is denied"
on line 2945, which is this:
if (document.documentElement.doScroll && !window.frameElement) (function(){
After some tracing, I found that the source of the problem is trying to access window.frameElement, which is forbidden in IE (if the host of the iframe is different in domain) for security reasons. Please check this for more information.
http://w3schools.invisionzone.com/index.php?showtopic=5868
http://w3schools.invisionzone.com/index.php?showtopic=5782
http://www.webmaster-talk.com/javascript-forum/57656-cross-domain-problem-for-iframe.html
I would be very thankful if you let me know when you fix this bug. Here is my email address:
rafidka@gmail.com
Regards,
Rafid
I found a solution for this bug. I added the following code to to know whether we are in iframe or not:
var notInFrame = true;
try {
notInFrame = !window.frameElement;
} catch(ex) {
If accessing the frameElement fails, a frame is probably in a different
domain than its parent.
notInFrame = false;
}
Then later, I used this line:
if ( document.documentElement.doScroll && notInFrame ) (function(){
instead of this:
if ( document.documentElement.doScroll && !window.frameElement ) (function(){
This solved the problem. Please check this for more information:
http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx