javascript - JS function execution order -


i have 2 pages namely parent.xhtml(controls layout) , child.xhtml(displays content). child page included in parent page using <iframe> tag.

i need implement onload functionality using javascript. before that, want know in order javascript functions execute?

will parent page js function execute first? or child page js function execute first?

awaiting answers.! in advance

according previous answer, browsers might not wait iframes load before firing onload event on parent window. can't make assumptions on 1 complete first - there's possibility of race condition going on there, either 1 finish first.

one solution might write function waits until it's been called number of times before executing:

var runs = 0; function onload() {     if (++runs < 2) return;     // put code execute once both have loaded } 

then in html:

<body onload="onload();">     .....     <iframe onload="onload();"> 

alternatively, set url of iframe in onload handler of parent window.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -