|
|
 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

June 28th, 2006, 11:49 PM
|
|
Authorized User
|
|
Join Date: Feb 2006
Location: Bay Area, CA, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
window.onload with arguments.
I want to run a function when the page loads, but I don't want to declare it in the body tag.
Code:
<body onload="thisfunc();">
Instead, I'm using window.onload to process it directly in the script. Now, I know that when you call a function with window.onload, you don't use the parentheses, so that the script runs the function, instead of assigining it.
But what if you have a function with arguments? How do you call it with window.onload?
|

June 29th, 2006, 03:02 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 685
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
One way would be something like...
Code:
window.onload = new Function("myFunc('x', 'y', 'z');");
function myFunc(a, b, c){
alert(a + b + c);
}
HTH,
Chris
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Onload with AJAX |
Baco |
Intro Programming |
0 |
June 11th, 2007 12:46 PM |
| onLoad functionality |
NEO1976 |
Javascript |
0 |
May 23rd, 2006 09:38 AM |
| iframe onLoad |
darkhalf |
Javascript |
1 |
January 11th, 2006 03:42 PM |
| audio onLoad |
Larson |
HTML Code Clinic |
2 |
February 20th, 2004 11:39 PM |
| two script onLoad |
mateenmohd |
Javascript |
2 |
December 27th, 2003 11:12 PM |
|
 |