Multiple JavaScript Onloads -


I am not a JS expert, so any help on this will be appreciated. I need to run on the page, which is the script below, first to prevent a white flash is a fix when the next iframes will load. The last part of the script will load an iframe based on the CSS media screen (different size iframe for different view ports). The problem is that when both are added, use an oload function and because there are two, only the last is being used and thus renders the first onload useless.

How can I get these two to work?

Code:

  & lt; Script type = "text / javascript" & gt; // Prevent Variable from Being Global (function () {var div = document.createElement ('div'), ref = document.getElementsByTagName ('base') [0] || document.getElementsByTagName ('script') [0] ]; Div.innerHTML = '& amp; shy; & lt; Style & gt; Ipham {visibility: hidden;} ; ref.parentNode.insertBefore (div, ref); window.onload = Function () {div.parentNode .removeChild (div);}}) (); Onload = function () {var el1 = document.getElementById ("frameContainer") el1.innerHTML = "& lt; iframe src = \" http: //energyamplified.co.za/animation_medium.html \ "& gt; & lt ; / Iframe & gt, "Var el2 = document.getElementById (" frameContainer_medium ") el2.innerHTML =" & lt; iframe src = \ "http: //energyamplified.co.za/animation_medium.html \" & gt; Lt; / iframe & gt; Var el3 = document.getElementById ("frameContainer_small") el3.innerHTML = "& lt; iframe src = \" http: //energyamplified.co.za/animation_small.html \ "& gt; & lt; / iframe & gt; " Var el4 = document.getElementById ("frameContainer_very_small") el4.innerHTML = "& lt; iframe src = \" http: //energyamplified.co.za/animation_very_small.html \ "& gt; & lt; / iframe & gt; " } & Lt; / Script & gt;  

Thanks,

b

You can make all calls to this one function, such as:

  & lt; Script type = "text / javascript" & gt; // Prevent Variable from Being Global (function () {var div = document.createElement ('div'), ref = document.getElementsByTagName ('base') [0] || document.getElementsByTagName ('script') [0] ]; Div.innerHTML = '& amp; shy; & lt; Style & gt; Ipham {visibility: hidden;} ; ref.parentNode.insertBefore (div, ref); window.onload = Function () {div.parentNode .removeChild (div); var el1 = document.getElementById ("frank Container"); el1.innerHTML = "& lt; iframe src = \" http: //energyamplified.co.za/animation_medium .html \ "& gt; & lt; / iframe & gt;; var el2 = document.getElementById (" framecontainer_midium "); l.minaryHTML =" & lt; iframe src = \ "http: // energyamplified. Co.za/animation_medium.html \ "& gt; & lt; / iframe & gt;" Var el3 = document.getElementById ("frankcontenter_ SMLL "); L. 3.innerHTML =" & lt; iframe src = \ "http: //energyamplified.co.za/animation_small.html \" & gt; & lt; / iframe & gt; "Var el4 = document GetElementById ("frameContainer_very_small"); El4.innerHTML = "& lt; iframe src = \" http: //energyamplified.co.za/animation_very_small.html \ "& gt; & lt; / iframe & gt;"; }; }) (); & Lt; / Script & gt;  

By the way, you can " Are losing


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -