SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Michigan
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 scripts with window.AddEvents negating one another

    Ok. I have 2 scripts that both have window.addEvent('domready',function(){ }) (whatever that is?) running on the same HTML document.

    Script 1 is included in the <head> of the document surrounded by <script language="javascript" type="text/ecmascript"> </script> tags which contains its "window.AddEvent".

    Script 2 is linked from the <head> of the document like so: <script language="javascript" type="text/ecmascript" src="js/script2.js"></script> and at the end of the actual script is the "window.AddEvent('domread',function(){})".

    When I remove either one, the other script works fine. If they are both present, the one that appears first in the section of the document, whether linked or internal will work and the script that follows will stop working.

    How can I make it so these two scripts coexist? Sorry, I'm still new at learning js so hopefully that was described well enough.

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Michigan
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, I'm not able to post the full scripts at this time but can share the relevant portions. I'm just wondering if this is a common issue and how to get around 2 scripts vying for window.AddEvent. Here is the window.AddEvent from each script:

    From script1:

    window.addEvent('domready',function(){

    var p = new mooSlide2({ slideSpeed: 1000, fadeSpeed: 500, toggler:'toggle2', content:'about', height:233, removeOnClick: true, opacity:'.99', effects:Fx.Transitions.Expo.easeOut , from:'top'});

    })


    From script 2:

    window.addEvent('domready',function(){

    var barservice = 0;
    var fass = 0;

    var p = $$('.fadein');
    p.each(function(el){
    el.effect('opacity',{ duration:2500, wait:false, transition:Fx.Transitions.Back.easeOut }).start(0,1);
    })


    var p = new avScroll({container:'innerScroller', imgWidth:260, scrollRange:24, leftHandle:'leftClicker',rightHandle:'rightClicker', rw:'leftFF', ff:'rightFF', speed:500});

    })


Bookmarks

Posting Permissions

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