Log in

View Full Version : Javascript Conflict



alinart
11-06-2009, 05:27 PM
I have two scripts that work on their own, but when I introduced magnify.js, simplecart.js stopped working. The files are:


http://artiztic.net/yoga/simplecart.js


http://artiztic.net/yoga/magnify.js

can someone please help me resolve this? I don't know enough about javascript and my efforts to pinpoint the issue haven't helped.

jscheuer1
11-06-2009, 06:11 PM
There is no:


http://artiztic.net/yoga/simplecart.js

alinart
11-06-2009, 06:52 PM
There is no:

sorry, there's a capital C

http://artiztic.net/yoga/simpleCart.js

jscheuer1
11-06-2009, 09:20 PM
Well OK, there's nothing jumping out at me. I do see that simpleCart has:


window.onload = simpleCart.initialize;

If magnify has anything similar in an on page script you haven't shown, or requires an onload event in the body tag of the page(s) using it, there would be a conflict there. Can you give me a link to a page where the two scripts are 'not playing well together'?

In any case though, I'd try this first - change (in simpleCart.js - at the end):


window.onload = simpleCart.initialize;

to:


if (window.addEventListener)
window.addEventListener('load', simpleCart.initialize, false);
else if (window.attachEvent)
window.attachEvent('onload', simpleCart.initialize);

If it's an onload conflict with magnify, this will resolve it.

alinart
11-06-2009, 10:14 PM
that didn't fix it unfortunately

This is one of the test pages
http://artiztic.net/yoga/item1.html

You can see the simpleCart.js works fine if you click on the Weightloss or Yogasports is Green tabs.

Also, on item pages without magnify.js such as http://artiztic.net/yoga/sport_pack.html

item1.html has magnfy.js and simpleCart.js on it

I appreciate your help.

alinart
11-06-2009, 10:17 PM
Nevermind it's working! had to empty my cookies. That change fixed it. Thank you so much!