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

    one javascript working instead of two

    Hi,
    when i insert second java scrip then first java script not working. I am showing script below

    <script type="text/javascript" src="scripts/jquery-1.4.1.min.js"></script>

    <script type="text/javascript" src="banner/engine1/jquery.js"></script>
    <script type="text/javascript" src="banner/engine1/slider.js"></script>
    <script type="text/javascript" src="banner/engine1/script.js"></script>

    <script type="text/javascript" src="jquery-ui-1.8.13.custom.min.js"></script>



    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="s3Slider.js"></script>

    <script type="text/javascript" src="banner/engine1/jquery.js"></script>

    <script type="text/javascript" src="banner/engine1/slider.js"></script>
    <script type="text/javascript" src="banner/engine1/script.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {
    $('#slider1').s3Slider({
    timeOut: 3000
    });
    });
    </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    This is a very common situation - one script clashes with another.

    There are two reasons why multiple scripts in the same page will not work together.

    a) duplicate global variable and/or function names (including loop counters etc.)
    b) multiple onload statements.


    You will need to examine your scripts to identify the problem. Another source of conflict arises from using two different Javascript frameworks - say jQuery and mootools.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Just to start with, you have *TWO COPIES* of jQuery in there! And two DIFFERENT VERSIONS, at that!
    <script type="text/javascript" src="scripts/jquery-1.4.1.min.js">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">

    And then for some very very SILLY reason, you are including the EXACT SAME code twice!!!

    These THREE FILES are both included TWICE:
    <script type="text/javascript" src="banner/engine1/jquery.js"></script>
    <script type="text/javascript" src="banner/engine1/slider.js"></script>
    <script type="text/javascript" src="banner/engine1/script.js"></script>

    At a *minimum* get rid of all the duplications!

    But you should probably start by removing *ALL* the scripts that you are *NOT* using.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    The question was rather unclear, but I interpreted it to mean that the problem arose when he added a new script

    <script type="text/javascript" src="s3Slider.js"></script>

    to his page.

    In other words, he confusingly showed his code without and with the additional script.
    I think that the code actually reads:-

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="s3Slider.js"></script>
    <script type="text/javascript" src="banner/engine1/jquery.js"></script>
    <script type="text/javascript" src="banner/engine1/slider.js"></script>
    <script type="text/javascript" src="banner/engine1/script.js"></script>

    The duplication doubtless arises from having the two slider scripts.
    Last edited by Philip M; 03-20-2013 at 08:43 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,607
    Thanks
    6
    Thanked 997 Times in 970 Posts
    RTFS (read the effin’ sticky)!


  •  

    Posting Permissions

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