Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 960731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:13:39+00:00 2026-05-16T01:13:39+00:00

I want to show a big Image when I press the small thumbnail. A

  • 0

I want to show a big Image when I press the small thumbnail. A simple Lightbox style script.

When I press the grey transparent overlay area around the image, the CSS and image is removed from view. This code is stripped down. Maybe missed something needed…

$(document).ready(function() {    
    $(".lightBobo").click(function(e) {
        e.preventDefault();  // prevent to open link in new window
        $(this).lightBobo();
    });
});

jQuery.fn.lightBobo = function(e) {
    if (e != undefined)
        e.preventDefault();

    return this.each(function() {
        var img = new Image();

        $(img).load(function() {
            imgW = img.width;
            imgH = img.height;

            var overlay = $("<div />");
            var container = $("<div />");
            // Lots of css styling for <div> overlay and container image...

            container.append(img); //add image to div
            $("body").append(overlay); //add overlay to body
            $("body").append(container); //add div to body
            overlay.fadeIn("fast", function() {
                container.show();
            });
            $(overlay).click(function() {
                removeDivs();
            });
            function removeDivs() {
                container.hide();
                overlay.fadeOut("fast");
                img = null;
                container = null;
                overlay = null;
                openImgSrc = "";
            }
        });
    });
}

The problem is IE(7) is not showing the image the second time I want to show it. I have to do a page reload to display the image again. It works in FF though.

When I use FireFox I can see in FireBug that the get appended to for each time I show the big image. And the “old” image get’s display: none; After 20 times I show the big image, I have 40 elements of Overlay and Container(image).

I can’t figure out how to rerun the lightBobo function when needed. So it workes in both IE and FF.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:13:40+00:00Added an answer on May 16, 2026 at 1:13 am

    I have found a solution. I changed lots of code. Specially the $(img).load(function() { ... } where I was having some problems. I dont really know WHY the load() function didnt want to kick the event more than one time. So I removed most code out of that function.

    Remember the $(img).load(function() { ... } is for loading the image BEFORE finding its width and height. otherwise its 0.

    $(document).ready(function() {
    
        $(".lightBobo").click(function(e) {
            if (e != undefined)
                e.preventDefault();
            $(this).lightBobo();
        });
    });
    
    jQuery.fn.lightBobo = function(e) {
        return this.each(function() {
    
            var myClickedObj = $(this);
            //check if we have a anchor or image tag
            var src = "";
            if (this.tagName.toLowerCase() == "a")
                src = this.href.toLowerCase();
            else if (this.tagName.toLowerCase() == "img")
                src = this.src.toLowerCase();
            else
                return;
    
            var winW = $(window).width();
            var winH = $(window).height();
            var docH = $(document).height();
            if (docH < winH)
                docH = winH;
    
            //the semitransparant overlay over the whole page
            var overlay = $("<div />")
                .attr("class", "bobOverlay") //used as id for closing all overlays
                .css("background", "#000")
                .css("opacity", "0.8")
                .css("display", "none")
                .click(function() { hideAll(); })
    
            $("body").append(overlay); //add overlay to body
    
            var loadLeft = (winW / 2) - (100 / 2);
            var loadTop = (winH / 2) - (20 / 2) + $(document).scrollTop();
    
            overlay.fadeIn("fast");
    
            //an element to hold our picture
            var container = $("<div />");
            container.attr("class", "bobOverlay");
            container.hide();
    
            var img = new Image();
            $(img).load(function() {
               var imgW = img.width;
               var imgH = img.height;
    
               container.append(this); //add the picture to the container
           $("body").append(container); // add container to the body
               container.fadeIn("fast"); //show container
           })
       .attr("src", src); //add the src to the image
    
            function hideAll() {
                $(".bobOverlay").fadeOut("fast");
            }
            function IsImage(filename) {
                var ext = filename.split('.').pop().toLowerCase();
                var allow = new Array("gif", "png", "jpg", "jpeg", "bmp");
                if (jQuery.inArray(ext, allow) == -1) {
                    return false;
                }
                return true;
            }
        });
    }
    

    Sorry for the long code. And finding out the answer myself…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a big project and I want to show user the information
I want to show multiple image in each cell of TableView which is coming
ListViewItem Contain one thumbnail, when the mouse over the thumbnail,I want to show a
i have a problem..my tabs name show too big i want it shows as
Big picture: I want to render an RGB image via GTK on a linux
So, this is my problem: I have this very big image, and I want
I'm trying to show a small loading image during a slow operation with jQuery
Am looking for a very pared down, simple image cycling plugin. I dont want
I have an image which is too big so by default I want it
I want show annotation view (above one of my pin) after load map. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.