views:

935

answers:

3

From the facebook canvas, I need to be able to access an iframe window. Normally you could do this with window.frames, but FJBS doesn't seem to allow access to the window object.

Has anyone figured out how to access window objects?

A: 

you could try this. Let me know how it works.

var myIframe = document.getElementById('myIframeId');

// could retrieve window or document depending on the browser
// (if FBJS allows it!?)
var myIframeWin = myIframe.contentWindow || myIframe.contentDocument;

if( !myIframeWin.document ) { //we've found the document
    myIframeWin = myIframeWin.getParentNode(); //FBJS version of parentNode
}
meouw
A: 

Browsers handle domain security on the principle of Same Origin Policy

And the laws of cross domain communication

Also you will find an interesting read on the creationg of read-write JS APIs on this blog post http://piecesofrakesh.blogspot.com/2007/11/how-to-build-readwrite-javascript-api.html

moha297
The question does not involve cross-domain scripting. The scripts are injected into Facebook's domain, the same domain where the iframe element lives.Facebook has changed the underlying prototypes to prevent access.
thesmart
are you creating the application in FBML? or iframe mode?From your comment I gather FBML
moha297
A: 

I am facing the same problem...

var myIframeWin = myIframe.contentWindow || myIframe.contentDocument;

not working on FBML pages... How to call iframe javascript from FNML parent page???

Komal