JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 3rd, 2004, 07:12 AM
ReformSchooler ReformSchooler is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 ReformSchooler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How to call and pass arguments to JS functions in external files w/o using body tag?

I want to replace <body onLoad="scaleWidth(240,450,500)" onResize="scaleWidth(240,450,500)"> with an XHTML 1.0 strict alternative.

I've already tried adding:

window.onload = scaleWidth;
window.onresize = scaleWidth;

to my external file. There were two problems with this "solution."

First, the function was called when the page first loaded but not when it was resized (only checked in IE6).

Second, I can't pass arguments from my XHTML page this way. I want to be able to pass arguments because I want to use this function in a template, with the arguments passed changing with the particular page the template creates.

Any ideas?

-- Chris

Reply With Quote
  #2  
Old February 3rd, 2004, 08:51 AM
ReformSchooler ReformSchooler is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 ReformSchooler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Here's the solution!

I got a reply to the same question on another forum. Here is the solution:


Place the following on the XHTML page:

<script type="text/javascript">

onload = onresize = function() {
scaleWidth(240,450,500);
}

</script>

-- Chris

Reply With Quote
  #3  
Old February 3rd, 2004, 06:53 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Whoa - I would never have tried that... looks very odd. Thanks for posting the reply.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #4  
Old February 5th, 2004, 04:41 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Wow, does that work?
I've never seen that type of syntax for js before!

ya learn something every day i guess
[and ya, i'm too lazy to try it out myself right now]

Reply With Quote
  #5  
Old February 13th, 2004, 09:37 PM
ReformSchooler ReformSchooler is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 ReformSchooler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, it works! (NT)

No text . . .

Reply With Quote
  #6  
Old February 13th, 2004, 11:34 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
heh, crazy...
i think we all learnt something today =)
(well, we all being at least me, myself and i)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > How to call and pass arguments to JS functions in external files w/o using body tag?


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 1 hosted by Hostway
Stay green...Green IT