By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

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

P: 10
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

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  window.onload = function() {
  3.     setTimeout(loadfunction,1000)
  4.  }
  6.  function loadfunction() {
  7.      document.getElementById("myiframe").src = ""
  8.  }
  9.  </script>
Apr 15 '12 #1
Share this Question
Share on Google+
1 Reply

P: 1,059
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
Apr 16 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.