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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conflicting Javascript - PLEASE HELP!

    I'm trying to get a javascript lightbox and a background image resize script to work on the same webpage but one's causing the other to work incorrectly. If anyone can help combine the 2 into a working script it would be hugely appreciated:

    <!-- BG script -->
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="supersized.2.0.js"></script>
    <script type="text/javascript">
    $(function(){
    $.fn.supersized.options = {
    startwidth: 640,
    startheight: 480,
    vertical_center: 1,
    slideshow: 0,
    };
    $('#supersize').supersized();
    });
    </script>


    <!-- lightbox script -->
    <script type="text/javascript" src="imagezoom.js"></script>
    <script type="text/javascript" src="mootools-1.2.4-core-yc.js"></script>
    <link href="imagezoom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    window.addEvent("domready", function() {
    initImageZoom();
    });
    </script>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    This happens often when you combine many JavaScript libraries / frameworks. It is impossible to say what you must do, except:

    1. learn JavaScript to be able to create your own codes and to understand the others.
    2. if you still need some ready-made codes, use as less as possible different libraries. Try to use, say, only JQuery. JQuery has a lot of add-ons, and so on.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It could be a matter of just doing this (add noconflict so jquery doesn't use $, it will use jQuery).
    Code:
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="supersized.2.0.js"></script>
    <script type="text/javascript">
    $.noConflict();
    jQuery(function(){
    jQuery.fn.supersized.options = {
    startwidth: 640,
    startheight: 480,
    vertical_center: 1,
    slideshow: 0,
    };
    jQuery('#supersize').supersized();
    });
    </script>
    Although I'm pretty sure there is a mootools lightbox add on too.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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