JQuery Novice to Ninja and Firefox

I am on Ch.4 and need some help with the custom lightbox. It works in Safari and Chrome, but not Firefox (3.6.8). I’ve been floundering on this one for awhile and could use some help with the cross browser struggle.


Everybody please calm down. I figured it out.

Get rid of: console.log(“The calculated position is:”);

Found the info in the “Novice to Ninja” forum.

Research before posting. Lesson learned.:nono:

Thanks for the response.

This is the JS:

$(‘a.lightbox’).click(function(e) {
$(‘body’).css(‘overflow-y’, ‘hidden’); // hide scrollbars!

$('<div id="overlay"></div>')
  .css('top', $(document).scrollTop())
  .css('opacity', '0')
  .animate({'opacity': '0.5'}, 'slow')
$('<div id="lightbox"></div>')
$('<img />')
  .attr('src', $(this).attr('href'))
  .load(function() {
  .click(function() {

return false;;


function positionLightboxImage() {
var top = ($(window).height() - $(‘#lightbox’).height()) / 2;
var left = ($(window).width() - $(‘#lightbox’).width()) / 2;
console.log(“The calculated position is:”);
‘top’: top + $(document).scrollTop(),
‘left’: left
console.log(‘A jQuery selection:’);

function removeLightbox() {
$(‘#overlay, #lightbox’)
.fadeOut(‘slow’, function() {
$(‘body’).css(‘overflow-y’, ‘auto’); // show scrollbars!

The HTML that it refers to looks like this:

<a class=“lightbox” href=“images/molotov.png”>molotov</a>

Hi kanesaws, welcome to SitePoint! :slight_smile:

Could you post a link to what you have currently, or some code that we could test out? Otherwise there’s not much anyone can do.