Javascript window onload

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Apr 2007
Posts: 1,109
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Javascript window onload

 
0
  #1
May 17th, 2009
hi, how to use the window onload event on javascript.. for example i got a function and i want that function to execute during page load. any ideas is greatly appreciated... thanks...
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: codestips is an unknown quantity at this point 
Solved Threads: 1
codestips codestips is offline Offline
Newbie Poster

Re: Javascript window onload

 
0
  #2
May 17th, 2009
Here is a sample code:
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function load()
  5. {
  6. //Put your code here
  7. }
  8. </script>
  9. </head>
  10.  
  11. <body onload="load()">
  12.  
  13. </body>
  14. </html>
Last edited by codestips; May 17th, 2009 at 8:45 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Javascript window onload

 
0
  #3
May 17th, 2009
The best way to do it:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>Test Page</title>
  4. <script type="text/javascript">var myFunc = function() {
  5. alert("Hello World!");
  6. };
  7.  
  8. window.onload = myFunc;
  9. </script>
  10. </head>
  11. <body>
  12. </body>
  13. </html>
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,109
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Javascript window onload

 
0
  #4
May 20th, 2009
thanks..
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 119
Reputation: JugglerDrummer is an unknown quantity at this point 
Solved Threads: 15
JugglerDrummer's Avatar
JugglerDrummer JugglerDrummer is offline Offline
Junior Poster

Re: Javascript window onload

 
0
  #5
May 20th, 2009
You can of course do it with W3 event listeners, IE attatch event, or JQuery as well, but you knew that.
92% of all statistics are made up on the spot.

If you found a post helpful, please click the "give XXX reputation" link, to show your appreciation to those who helped you. Thanks! :D
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 9
Reputation: koolhq is an unknown quantity at this point 
Solved Threads: 1
koolhq koolhq is offline Offline
Newbie Poster

Re: Javascript window onload

 
0
  #6
May 21st, 2009
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var x=0
  5. function displaymessage()
  6. {
  7. while (x==0)
  8. {
  9. x=0
  10. alert("NO!");
  11. }
  12. }
  13. </script>
  14. </head>
  15.  
  16. <body onload="displaymessage()">
  17. <form>
  18.  
  19. </form>
  20. </body>
  21. </html>
Last edited by Ezzaral; May 21st, 2009 at 1:26 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC