how to make.. window.onload = function() { ..load "before" main page loaded

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mardash
    New Member
    • Mar 2012
    • 10

    how to make.. window.onload = function() { ..load "before" main page loaded

    i have this script for delayed iframe and it work but it's executed after my whole web loaded due to (onload)

    so what i do to make it run before or during page loading .. ?


    this's my code

    Code:
    <script type="text/javascript">
     window.onload = function() {
        setTimeout(loadfunction,1000)
     }
    
     function loadfunction() {
     	document.getElementById("myiframe").src = "http://www.google.com/"
     }
     </script>
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    thats how onload works. your function will trigger when loading is finished, informing that your loading is finished. if it allows you to run before it finish loading, you would create trouble such as you might try to access unloaded objects or item. I would suggest you to follow different approach to achieve your goal

    Comment

    Working...