...

View Full Version : Conflicting Javascript - PLEASE HELP!



korpse
07-21-2010, 11:26 AM
I'm trying to get a javascript lightbox and a background image resize script to work on the same webpage but one's causing the other to work incorrectly. If anyone can help combine the 2 into a working script it would be hugely appreciated:

<!-- BG script -->
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
<script type="text/javascript" src="supersized.2.0.js"></script>
<script type="text/javascript">
$(function(){
$.fn.supersized.options = {
startwidth: 640,
startheight: 480,
vertical_center: 1,
slideshow: 0,
};
$('#supersize').supersized();
});
</script>


<!-- lightbox script -->
<script type="text/javascript" src="imagezoom.js"></script>
<script type="text/javascript" src="mootools-1.2.4-core-yc.js"></script>
<link href="imagezoom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
window.addEvent("domready", function() {
initImageZoom();
});
</script>

Kor
07-21-2010, 02:52 PM
This happens often when you combine many JavaScript libraries / frameworks. It is impossible to say what you must do, except:

1. learn JavaScript to be able to create your own codes and to understand the others.
2. if you still need some ready-made codes, use as less as possible different libraries. Try to use, say, only JQuery. JQuery has a lot of add-ons, and so on.

_Aerospace_Eng_
07-21-2010, 04:15 PM
It could be a matter of just doing this (add noconflict so jquery doesn't use $, it will use jQuery).

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
<script type="text/javascript" src="supersized.2.0.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(function(){
jQuery.fn.supersized.options = {
startwidth: 640,
startheight: 480,
vertical_center: 1,
slideshow: 0,
};
jQuery('#supersize').supersized();
});
</script>
Although I'm pretty sure there is a mootools lightbox add on too.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum