Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 3rd, 2003, 04:49 PM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
how to use two "onLoad"

I have two JavaScript code for onLoad.

<body marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus()" onResize="if (isNS4) nsResizeHandler()">


How do I combine the above one and the following one:

<body onLoad="javascript:startStatusScroller(statBarMsg);">


Reply With Quote
  #2  
Old October 3rd, 2003, 05:38 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: how to use two

you can do one of two things, first, you could include both function calls in the onload event,(seperated by a semicolon) or better yet, create a function that calls both functions and then call that from the onload event

Reply With Quote
  #3  
Old October 3rd, 2003, 06:16 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: how to use two

Couldn't you just do this?

<body
marginwidth="0"
marginheight="0"
style="margin: 0"
onLoad="writeMenus(); startStatusScroller(statBarMsg);"
onResize="if (isNS4) nsResizeHandler();"
>

-edit- sorry blindeddie, hadn't refreshed the page so didn't see u had replied. Having an extra function to do this is pointless, unless you will call these two things in multiple places.

Reply With Quote
  #4  
Old October 3rd, 2003, 06:48 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: how to use two

when I use javascript, I tend to use external javascript files that I share amongst all my pages, so it makes life easier for me to create a function that includes other function calls so that if I need to make a change to the function or add another function to an event, I only need to change it in one place. Hardly pointless from a coding and maintenance standpoint!

Reply With Quote
  #5  
Old October 3rd, 2003, 08:19 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: how to use two

I didn't atually look at what he was doing, just the syntax. It is likely that many of his pages will have the same body onLoad's, so obviously a function in a shared script would be better.

I don't believe this is always the case, though. I wouldn't discount having multiple statements on an event handler.

In a structured programming sense, you could put all your javascript in one file to modify it centrally, but this is really a matter of taste. Personally I prefer code that only applies to one page or one section to be seperate from the more general stuff.

Reply With Quote
  #6  
Old October 3rd, 2003, 10:18 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: how to use two

I do not discount multiple statements in event handlers, in fact I have used them quite often. I do like to take the approach of trying to use shared files whenever possible without having to many unshared functions in the file. This can somtimes be a little difficult, but with proper planning it makes for a nice system. all in all it is my personal preference to do it this way but any way that works is fine by me...

Reply With Quote
  #7  
Old October 3rd, 2003, 10:50 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: how to use two

I agree with you 100%. It is easy to fall into the trap of writing code without thinking ahead. Luckily I seem to have enough experience to avoid most pitfalls.

However I often find myself rewriting pieces of code a few weeks later since I have found a more efficient way to do it. If you put more work in at the beginning, you will have less work later.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > how to use two "onLoad"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT