Jump to content

Scripts conflict with each other.


acctman

Recommended Posts

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();

});

});

 

Link to comment
https://forums.phpfreaks.com/topic/161383-scripts-conflict-with-each-other/
Share on other sites

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.