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 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    86
    Thanks
    2
    Thanked 1 Time in 1 Post

    Two scripts conflicting ?

    Hi guys I have to scripts on my page and they work fine on their own but when i put them together one stops working ??

    One is the colorbox script and the other toggles some hidden content.

    Any ideas why they wont work on the same page ?

    This is whats in my head section and the start of the body section

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="../../js_files/jquery.easing.1.3.js"></script>
    <script type="text/javascript" src="../../js_files/jquery.tools.min.js"></script>
    <!--[if lt IE9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <link rel="stylesheet" href="../../colorbox/colorbox.css" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script src="../../colorbox/jquery.colorbox-min.js" type="text/javascript"></script>
    <script type="text/javascript">
    		$(document).ready(function(){
    			//Examples of how to assign the ColorBox event to elements
    			$("a[rel='slides']").colorbox({transition:"none", width:"70%", height:"70%", scalePhotos:false});
    		});
    </script>
    </head>
    
    <body>
    <script language="JavaScript" type="text/javascript">
         $(function() {
          $("#tabs").tabs("#tabscontent section", {
            effect: 'fade',
            fadeOutSpeed: 0,
            fadeInSpeed: 400
          });          
         });
    </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    This question has been asked and answered a zillion times in this forum.

    There are two basic reasons why scripts will not work together.

    a) duplication of function and/or variable names between the scripts - the second will over-write the first.
    b) multiple onload statements.
    See:- http://www.javascriptkit.com/javatut...iplejava.shtml
    http://www.dyn-web.com/tutorials/combine.php


    "It's so simple to be wise. Just think of something stupid to say and say the opposite." - Sam Levenson

    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
    New Coder
    Join Date
    Aug 2002
    Posts
    86
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hi,

    Thanks for your help.

    Would it work if i wrapped both the code snipets there in a new function and then called both those functions from the body onload call ?


  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by waps2 View Post
    Hi,

    Thanks for your help.

    Would it work if i wrapped both the code snipets there in a new function and then called both those functions from the body onload call ?

    Assuming that the trouble is multiple onloads, then you can use

    <script type="text/javascript">
    window.onload = function() {
    functionOne();
    functionTwo();
    }
    </script>

    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
    New Coder
    Join Date
    Aug 2002
    Posts
    86
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hi Philip

    Thanks for helping me. I tried that method but doesnt appear to want to work.

    So must be another problem. Conflist of function name maybe like you suggested ?

    I have no idea where to start though on this one

  • #6
    New Coder
    Join Date
    Aug 2002
    Posts
    86
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hi,

    Not to worry I figured it out now yay lol

    It was a function name conflict and also I was trying to include two jquery library files.



  •  

    Posting Permissions

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