Setting Javascript context for iFrame in iFrame
I have a page with <iframe>
and inside <iframe>
another one appears <iframe>
as a window. What I am trying to do is call the taht function set to <iframe>
<iframe>
.... I know a lot of the same tag is going on.
This is what I mean in HTML format.
<body>
<iframe src="blahblah.html" name="iframe">
//blahblah.html html
<iframe src="blahblahpopup.html" name="iFrame2">
//blahblahpopup.html html, also where the function is set.
</iframe>
</iframe>
</body>
So, as you can see, <iframe>
there is <iframe>
.
Now let's get down to business. I am using this JS code to get my JS context in the first level <iframe>
named "iframe"
window.frames['iframe'].showAssetPicker();
What it means is it brings up a popup inside the first level <iframe>
. But now I need to call a function inside the popup that was just called. (which is another <iframe>
... I am not the cause of all <iframe>
...)
So my unsuccessful attempt at calling a function defined at the second level <iframe>
...
window.frames['iframe'].frames['iFrame2'].populateTypePullDown('/vsg/ipm/SecuredOfferRepository');
I have also tried
window.frames['iframe'].window.frames['iFrame2'].populateTypePullDown('/vsg/ipm/SecuredOfferRepository');
Nothing works. Any help on this? I am using node-webkit to remove security restrictions <iframe>
.
Thanks for any help you can throw at me!
PS Good God, I've said <iframe>
too many times in this post.
source to share
Probably the problem is that you are not waiting for the Asset Picker to load and therefore the function populateTypePullDown
has not been defined yet.
Try something like this:
$('#iframe')
.ready(function() {
var $innerIframe = $(this).contents().find('#iFrame2');
console.log($innerIframe, 'ready');
$innerIframe.get(0).contentWindow.populateTypePullDown('/vsg/ipm/SecuredOfferRepository');
})
.get(0).contentWindow.showAssetPicker();
source to share