Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

two conflicting scripts (JavaScript)

Featured Replies

I'm using two scripts on single page and I'm not having experience in that. First is slideshow and second is lightbox. When I insert lightbox code (paths to lightbox files) slideshow stops working. Without lightbox everything works fine. Can anyone help me?

 

 

<link href="design.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>

<!-- InstanceBeginEditable name="head" -->
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

<script type="text/javascript">  
function slideSwitch() {
   var $active = $('#slideshow IMG.active');

   if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

   // use this to pull the images in the order they appear in the markup
   var $next =  $active.next().length ? $active.next()
       : $('#slideshow IMG:first');



   $active.addClass('last-active');

   $next.css({opacity: 0.0})
       .addClass('active')
       .animate({opacity: 1.0}, 1000, function() {
           $active.removeClass('active last-active');
       });
}

$(function() {
   setInterval( "slideSwitch()", 3500 );
});
</script> 

<style type="text/css"> 

/*** set the width and height to match your images **/

#slideshow {
   position:relative;
   height:613px;
}

#slideshow IMG {
   position:absolute;
   top:0;
   left:0;
   z-index:8;
   opacity:0.0;
}

#slideshow IMG.active {
   z-index:10;
   opacity:1.0;
}

#slideshow IMG.last-active {
   z-index:9;
}

</style>  
<!-- InstanceEndEditable -->

Lightbox never works well with jQuery; Lightbox uses the Prototype library, jQuery is a different library, the whole thing just gets messy.

 

Have a quick Google for "jquery lightbox" - there's a free one out there that looks the same and uses jQuery. If you use that, you can take Scriptaculous, Prototype and your current lightbox off your page - that will sort out most of your problems.

 

Incidently, now is a great time to upgrade your version of jQuery - 1.2 is very old. The current version is 1.6 and it's a lot faster and can do more things.

Lightbox never works well with jQuery; Lightbox uses the Prototype library, jQuery is a different library, the whole thing just gets messy.

 

Have a quick Google for "jquery lightbox" - there's a free one out there that looks the same and uses jQuery. If you use that, you can take Scriptaculous, Prototype and your current lightbox off your page - that will sort out most of your problems.

 

Incidently, now is a great time to upgrade your version of jQuery - 1.2 is very old. The current version is 1.6 and it's a lot faster and can do more things.

 

This.

 

Or failing that, you could use jQuery's noConflict to run your scripts without worry of them getting in each other's way.

 

The noConflict allows you to pass control of $ back to the other library, in this case, Prototype.

 

http://api.jquery.com/jQuery.noConflict/

  • Author

Thanks!!! I've done it.

 

I used jQuery Lightbox, page are loaded faster and everything is simpler. Using prototype.js Lightbox with other scripts is really messy.

Also, I tried noConflict but jQuery Lightbox seems to be better solution.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.