Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,803
    Thanks
    19
    Thanked 157 Times in 148 Posts
    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...
    Last edited by chump2877; 05-27-2012 at 06:52 PM.
    Regards, R.J.

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

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •