acctman Posted June 8, 2009 Share Posted June 8, 2009 The two scripts below are have a conflict with each other. Script 1 is generating an error in script 2. If i remove script 1 everything works fine in script2. Script 2 is more important that script1 which just display a headline every fee seconds. is there anything i can do to fix script 1 and stop it for throwing an error This script which is not related to another scriipt is causing an error. Script 1 <input id="foo" size="60" type="text"> <script type="text/javascript"> $ = function(e) {return document.getElementById(e);}; var display = function(el) { var msg = [ "Test1.", "Test2.", "No Advertising of other Sites."], e = $(el), c = "count", timer = 6500; if (typeof e[c] == "undefined") { e[c] = -1; }; if (e[c] > msg.length-2) { e[c] = 0; } else { ++e[c]; }; e["value"] = msg[e[c]]; var t = setTimeout(function() {display(el);}, timer); }; display("foo"); </script> 'null' is null not an object Line2 Char2 Script 2 $(document).ready(function() { $("#open").click(function(){ $("div#panel").slideDown("slow"); return false; }); // Collapse Panel $("#close").click(function(){ $("div#panel").slideUp("slow"); return false; }); $("#toggle a").click(function () { $("#toggle a").toggle(); }); }); Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted June 8, 2009 Share Posted June 8, 2009 looks like you're using jQuery. If that is the case you don't need the function $(); Just remove the script 1. and use the $() function inside jQuery Quote Link to comment Share on other sites More sharing options...
acctman Posted June 8, 2009 Author Share Posted June 8, 2009 looks like you're using jQuery. If that is the case you don't need the function $(); Just remove the script 1. and use the $() function inside jQuery $ = function(e) {return document.getElementById(e);}; should be $(e) {return document.getElementById(e);}; Quote Link to comment Share on other sites More sharing options...
chronister Posted June 8, 2009 Share Posted June 8, 2009 JQuery can work with other libraries.... your problem here is that they are both wanting to use the $ namespace. Check out this reference with using jQuery.noConflict(); http://docs.jquery.com/Using_jQuery_with_Other_Libraries It allows you to just use the jQuery namespace or assign a new namespace to jquery. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.