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
Post a Comment