SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Chameleon's Avatar
    Join Date
    Oct 2004
    Location
    Arizona
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Works in Chrome but not Safari, Firefox or IE

    This code is working in Chrome but its not working in Firefox, Safari or IE.

    Why it wont I cant figure out!!! Please help.

    Code JavaScript:
    jQuery(document).ready(function($) {
     
      // global variables for script
      var current, size;
     
      $('.aggressive_lightbox_video').click(function(e) {
     
        // prevent default click event
        e.preventDefault(); 
     
        // determine the index of clicked trigger
        var slideNum = $('.aggressive_lightbox_video').index(this);
     
        // find out if #lightbox exists
        if ($('#aggressive_lightbox_video').length > 0) {        
          // #lightbox exists
          $('#aggressive_lightbox_video').fadeIn(200);
          // #lightbox does not exist - create and insert (runs 1st time only)
        } else {                                
          // create HTML markup for lightbox window
          var aggressive_lightbox_video = 
    			'<div id="aggressive_lightbox_video">' +
    			'<p class="close">X Close</p>' +
    				'<div id="aggressive_lightbox_video_container">' +
    					'<ul></ul>' +
    				'</div>' +
    			'</div>';
     
          //insert lightbox HTML into page
          $('body').append(aggressive_lightbox_video);
     
          // fill lightbox with .lightboxTrigger hrefs in #imageSet
          $('div#videos').find('li a').each(function() {
            var $href = $(this).attr('href');
    		var $post_title = $(this).closest('li').find('p').text();
            $('#aggressive_lightbox_video_container ul').append(
              '<li>' +
    		  '<h3 class="lightbox">' + $post_title + '</h3>' +
    		  '<iframe width="853" height="480" src="' + $href + '?rel=0" frameborder="0" allowfullscreen></iframe>' +
    		  '</li>'
            );
          });
     
        }
     
        // setting size based on number of objects in slideshow
        size = $('#aggressive_lightbox_video_container ul > li').length;
     
        // hide all slide, then show the selected slide
        $('#aggressive_lightbox_video_container ul > li').hide();
        $('#aggressive_lightbox_video_container ul > li:eq(' + slideNum + ')').show();
     
        // set current to selected slide
        current = slideNum;
      });
     
      //Click anywhere on the page to get rid of lightbox window
      $('body').on('click', '#aggressive_lightbox_video', function() { // using .on() instead of .live(). more modern, and fixes event bubbling issues
        $('#aggressive_lightbox_video').fadeOut(200).remove();
      });
     
      // show/hide navigation when hovering over #slideshow
     
      // navigation prev/next
      $('body').on('click', '.slide-nav', function(e) {
     
        // prevent default click event, and prevent event bubbling to prevent lightbox from closing
        e.preventDefault();
        e.stopPropagation();
     
        var $this = $(this);
        var dest;
     
        // looking for .prev
        if ($this.hasClass('prev')) {
          dest = current - 1;
          if (dest < 0) {
            dest = size - 1;
          }
        } else {
          // in absence of .prev, assume .next
          dest = current + 1;
          if (dest > size - 1) {
            dest = 0;
          }
        }
     
        // fadeOut curent slide, FadeIn next/prev slide
        $('#aggressive_lightbox_video_container ul > li:eq(' + current + ')').fadeOut(550);
        $('#aggressive_lightbox_video_container ul > li:eq(' + dest + ')').fadeIn(550);
     
        // update current slide
        current = dest;
      });
    });
    ;

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Chameleon View Post
    This code is working in Chrome but its not working in Firefox, Safari or IE.

    Why it wont I cant figure out!!! Please help.
    Please provide some HTML that works with the scripting code so that we may more effectively test your code.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •