View Full Version : One script causes another not to work

02-09-2009, 10:24 PM
1) Script Title:
Facebox + external image gallery script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex4/facebox/index.htm + ?

3) Describe problem:

My problem relates to scripts on this site as well as other scripts. I loaded both facebox script and a image gallery script from another site. It seems that having both externally linked scripts loaded at once will cause one or the other not to work. One script might not work if say another script is loaded, so it will have to be removed for the other script to work. Would anybody have any suggestions why this would happen? Perhaps duplicate function or prototype declarations...? Or maybe having more than one style sheet linked in could also be adding to the problem? I really enjoy a lot of these scripts especially modifying them to suite my needs, but this is a strange problem that i've never encountered before. Any help or suggestions would be greatly appreciated, thanks.

02-09-2009, 10:58 PM
Multiple onloads may cause problems. Here's a script that deals with it. Suppose you want to do the following onloads (which might conflict): onload1() and onload2(). Then you do:
<script type="text/javascript">
/*found at http://simonwillison.net/2004/May/26/addLoadEvent*/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
addLoadEvent(function() {

02-10-2009, 10:22 AM
There is no onload conflict with Facebox, it uses the jQuery document.ready method, which in turn uses the addEvent/attachEvent methods, which don't conflict. Multiple stylesheets will only be a problem if the actual styles in them contradict each other. I'm guessing that you are using another library with the other script that conflicts with jQuery. jQuery can be run in no conflict mode though that doesn't always resolve all issues with other libraries. Often the best solution is to find a substitute for the other script, one that functions like it, but that uses the jQuery library.

If you want more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.