javascript - Invoking a function in an iframe from the parent window -


i can't figure out i'm doing wrong here.

i building website no server-side have main page iframe , on button click want iframe's src change , function in invoked passed parameter.

the function not called reason.

here's code:

the iframe:

<iframe id="main_area_frame" name="main_area_frame" src="" frameborder="0" width="100%"     height="100%"></iframe> 

the onclick function:

function onsubmenuclick(images) {     //set images frame     main_area = document.getelementbyid("main_area_frame");     main_area.src = "imagesframe.html";     main_area.contentwindow.initializeimages(images); } 

the function in iframe(imagesframe.html):

function initializeimages(imagesstr)  {     alert("initializeimages");     ... } 

some weird things noticed that

when adding alert before main_area.contentwindow.initializeimages(images); function somehow called successfully.

if set iframe's src begining , skip line main_area.src = "imagesframe.html"; - function again, called.

any ideas?

not sure if cause, try putting delay(sleep) between

main_area.src = "imagesframe.html"; 

and

main_area.contentwindow.initializeimages(images); 

in order allow iframe rendered (i not know if rendered same frame or browser launches new one).

just 2 cents.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -