Is there a way to access an iframe window object from a canvas in FBJS? (Facebook)

From facebook canvas i need to have access to iframe window. You can usually do this with window.frames, but FJBS doesn't seem to allow access to the window object.

Has anyone understood how to access window objects?

+3
source share
2 answers

you can 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
}
+10
source

Source: https://habr.com/ru/post/1702725/


All Articles