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-27-2012, 06:26 PM   PM User | #1
bubulac
New to the CF scene

 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bubulac is an unknown quantity at this point
Multiple scripts conflict?

Hello everybody,
I hope I can get some help here with a possible script conflict.
I have a script for a popup calendar (http://www.epoch-calendar.com/javasc...dar/index.html) that requires the following initialization:

Code:
<script type="text/javascript">
var calendar1; /*must be declared in global scope*/
/*put the calendar initializations in the window's onload() method*/
window.onload = function() {
calendar1 = new Epoch('today','popup',document.getElementById('today'),false);
calendar2 = new Epoch('LMP1','popup',document.getElementById('LMP1'),false);
};
</script>
It works well as long as the <body> tag doesn't have any other onload functions added.

However, if I try to add other scripts (freehand drawing, etc) that would make the <body> tag look like this:
Code:
<body onload="init(); ReloadImage(); SetSwitchOn('Freehand'); checkIt();">
nothing works anymore, neither the calendar nor the other functions.
Any suggestions?...
Thank you in advance.
bubulac is offline   Reply With Quote
Old 05-27-2012, 06:35 PM   PM User | #2
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
The DOM 'window' can only have one onload event handler...So you'll need to combine all of your onload event code into a singe event handler.

In your case:

Code:
<body>
<script type="text/javascript">
var calendar1; /*must be declared in global scope*/
/*put the calendar initializations in the window's onload() method*/
window.onload = function() {
init(); 
ReloadImage(); 
SetSwitchOn('Freehand'); 
checkIt();
calendar1 = new Epoch('today','popup',document.getElementById('today'),false);
calendar2 = new Epoch('LMP1','popup',document.getElementById('LMP1'),false);
};
</script>
Edit: See this link...
__________________
Regards, R.J.

---------------------------------------------------------

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)

Last edited by chump2877; 05-27-2012 at 06:52 PM..
chump2877 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 02:57 PM.


Advertisement
Log in to turn off these ads.