Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-20-2009, 05:37 AM   PM User | #1
utsav
New to the CF scene

 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
utsav is an unknown quantity at this point
2 javascripts not working in 1 page.

I need two or more javascripts in one page. But the problem is that when i put one or more javascript only the last one works while others donot work. But when single all work fine. What could be the problem?
utsav is offline   Reply With Quote
Old 05-20-2009, 06:24 AM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
try to combine the init() functions that define the two scripts into one new init(). Use alerts in each step to see where the eroor is coming from.
TinyScript is offline   Reply With Quote
Old 05-20-2009, 07:11 AM   PM User | #3
adios
Senior Coder

 
Join Date: Jun 2002
Posts: 1,404
Thanks: 2
Thanked 32 Times in 32 Posts
adios is on a distinguished road
Or ... look for one (or all) of these:

window.onload = something;
onload = something;
<body .... onload="something()">

All are the same; they refer to a variable called 'onload.'
Only one per customer.

Read this.

Last edited by adios; 05-20-2009 at 07:14 AM..
adios is offline   Reply With Quote
Old 05-20-2009, 07:21 AM   PM User | #4
bigtiger
New Coder

 
bigtiger's Avatar
 
Join Date: Oct 2005
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
bigtiger is an unknown quantity at this point
Hmmm...
This may also work but should be used when none of works
ie, document.attachEvent
ff, document.addEventListener

these will allow attach more than one even handler on a page.
__________________

what ever you are, I will be there !!
[ pixy ] [ FrontPage] [ ThreeColumnLayouts] [ wellstyled ][ quirksmode.org ]
bigtiger is offline   Reply With Quote
Old 05-20-2009, 08:15 AM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
http://www.javascriptkit.com/javatut...iplejava.shtml

It should be mentioned that another possible problem is duplication of one or more function and/or variable names between the two scripts.
Philip M is offline   Reply With Quote
Old 05-20-2009, 12:12 PM   PM User | #6
utsav
New to the CF scene

 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
utsav is an unknown quantity at this point
Thanks every body. I'll go thru all of ur steps and let u know what happened.
utsav is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:30 AM.


Advertisement
Log in to turn off these ads.