iPhone App Con Sept 27 -- www.iphonedevcon.com
Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 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
Send a message via AIM to dimo414 Send a message via Yahoo to dimo414
Default 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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 29th, 2006, 03:02 AM
Friend of Wrox
Points: 1,374, Level: 14
Points: 1,374, Level: 14 Points: 1,374, Level: 14 Points: 1,374, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 685
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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



All times are GMT -4. The time now is 03:46 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc