I made a method to scan the object structure and try to find objects stored under the key $
and jQuery
.
Attention: here it took about 30 seconds to finish, but it may take longer.
The search has a maximum depth of 4 levels.
That way, you can see that it works:
var iframeWindow = $("#frame").get(0);
var frame$ = iframeWindow.contentWindow.$;
Note: it will not be possible to find the variable if Iframe is not of the same origin as the container, because the browser will block it otherwise. Probably if you configure the server’s CORS to accept sharing resources, ai will be possible, but in this case you will need to have control over the server that provides Iframe content.
Create an empty Iframe in the hand, leaving the src
blank will also cause your access to Iframe variables to be blocked. I tested with the example you provided at first and it didn’t work.
jsfiddle - proving it doesn’t work that way
Mister Tuyoshi, would you better explain your question...
– Silvio Andorinha
@In the small forest I have an iframe that has the jQuery embedded, I need to recover jQuery instance of iframe.
– Tuyoshi Vinicius