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 512713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:20:53+00:00 2026-05-13T07:20:53+00:00

Imagine a lightbox with a beautiful picture inside it and a button somewhere near

  • 0

Imagine a lightbox with a beautiful picture inside it and a button somewhere near to navigate to the next picture…

When the user clicks the next button, JS does like so:

var Image = new Image();
Image.onload = getWidth;
Image.onerror = getFailure; 
Image.src = "http://somewebsite.mr/pics/4.png";

Then when the picture is loaded, JS goes into the getWidth function in order to find out the width of the picture:

w = this.width;  //height is not needed as CSS will adjust it correctly

After that, JS changes the width of the lightbox according to the width of the picture (with a bit add of paddings to make a border). And then, JS changes the src attribute of the picture, currently being shown in the lightbox, to the http://somewebsite.mr/pics/4.png. This changes the picture in the lightbox…

Is that the way lightboxes are built? This works, but I need ensure that it is cross-browser and works fine no matter what. Could you please tell me what you know about developing lightboxes? Is there another way of doing the job? Maybe you know some issues that could harm that program?

EDIT: My concern is whether there is something wrong with image preloading in the case of lightboxes or not. Would it be cross-browser? I know about the rest of the work. I just need to know how change pictures in a lightbox. I’m just new to the image preloading thing. Is it a main technique?

  • 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-13T07:20:53+00:00Added an answer on May 13, 2026 at 7:20 am

    Your concept sounds about right. However, when creating a lightbox, there are numerous cross-browser issues to be aware of. I do not know of a manual or article that lists them all, but maybe you can find inspiration looking into the source code of other lightboxes. I personally have found Greg Neustaetter’s multi faceted lightbox very easy to understand and customize.

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

Sidebar

Related Questions

No related questions found

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.