Lightbox JS - update
Now with captions! I’ve also fixed a couple of minor issues involving extra-large images falling out of the viewport and a small gap in the overlay in Firefox. Also, it’s more keyboard friendly now. Thanks for all the comments and suggestions.
Grab the latest files here: Lightbox JS
Just a teaser, but per many requests for extended functionality, I am working on a complimentary ‘photo-gallery’ script. It will include forward/back navigation, preloading, and much more. Check back next week.
Thanks for the excellent script. One question, how could I put a link in the attributes? For example, link to another page or action.
Tracey, Are you talking about a link below the enlarged image?
We’re working on that right now (a close link as well as a ‘print this image’ link that will launch a different file w/ printing options attached).
I’ll post when finished.
Thanks, you are are Champion, i found this website this morning (Australian time) and it was pefect except that it didn’t have captions, i thought to myself, no biggy i will add captions to it… i come back this afternoon and a new feature has been added. THanks heaps, you have saved me alot of time making this same thing for myself!!!
Tracey, here’s a hack-job I’ve been working on to get links working:
http://www.osnap.net/sandbox/sandbox_lightbox.php
It’s got a way to go, and maybe somebody else can clean the bugger up :)
Awesome script!
But I’ve got one issue—how can I get this work with image maps? My client’s website has ‘chunk’ images that need to have 4 or 5 links coming off each one. Right now, we’re just using image maps. We want to use your script, but can’t get it to work with them. It’s something with the “Rel=” not working on the link.
Thanks for anyhelp!
Ben
I have a flash nav bar on my site, which doesn’t get ‘overlaid’ with the lightbox, does anymore have any suggestions to to overlay the flash window, i have already tried changing the z-index, no avail. Thanks in advance
Awesome Script! Very nice and clean and functional.
I have one question, is there a way to position the full size image on the page? Maybe within an exixting ?
Thanks,
Sean
Andy: this is beacuse by default Flash is above of all elements. You can read it here (http://joshuaink.com/blog/82/flash-content-and-z-index) how to avoid this.
Hi there, nice script!!
I have been trying to combine the moo.fx Opacity effect ( a superlightweight javascript effects library ) with this script and I can’t find the way to make it happen. … any help in this?
this is my test page: http://dismorfofobico.com/test.html
Sweet, thanks.
Excellent !
The bug mentionned here : http://www.lokeshdhakar.com/2006/01/02/lightbox-js/#comment-374
has been solved by this update.
Thank you very much :)
Very nice script indeed!
Would it be possible to resize the images before display dynamically based on browser window width? I have many large images (of varying width) and I would like them to appear at about 70% of the browser width (with height set automatically, so as to preserve aspect ratio). I tried doing this with a few changes to the CSS and script, but I didn’t get very far.
@Alberto Ortiz Flores:
check out the onload events! put the onload events of moo.fx in the
Lightbox.js file( at the bottom) and test from there? Dont know if it will work but this is often a problem with javascripts….
well done !
just a suggestion : if you add an iframe methode on your script it will allow us to pen a form, or any other page with the same effect ;)
regards.
Safari 1.2.3 (v125.9) displays the image top left so the loading graphic looks a bit funny. Do you think it’s possible to add a history marker, so pressing back takes you to the page with the photos, rarther than the page before the photos if you catch my drift.
Excellent Script. Thanks for sharing.
Used this script for the first time today, very nice and very quick to implement, good work sir!
The only initial problem I found was that in IE, drop downs do not get overlaid and as mine was unfortunately in the middle of the page, it looked rather silly. Changing the z-index didn’t seem to make any difference so the only resolution I could think of was to hide all select boxes by putting in…
var objSelects = document.getElementsByTagName(’select’);
for(var i=0;i
Clearly this comment board does not like code!
Great!!! its a very good script ! thank you very much
soon oon www.gandoulfe.com
well done
Is it possible to hack this script for this :
Zooming is available to all pictures : larger than specified manually and in a particular id (div or class).
It will be very interresting in a weblog view. No more to resize picture in posts. If there are pictures in posts larger than what i’v specified then this javascript work.
Thank you for your work :)
This is a pretty slick script. It will definitely be handy in my next gallery.
Anyone know if there’s a way to get this script to display an entire article instead of an image? I’m working on a site now where a feature like that would be pretty slick on. Just display the entire contents of the article in a div (even allowing links and images within the article) and have a close button at the top or bottom. That’s just my initial thinking. But I’m not sure how to do it.
Any help would be greatly appreciated.
thank you! :)
Ross Coombes:
Another way to overlay the form elements that seem to want to pop through the image is to change the “overlay” object in the code to an iframe and add a filter. It does nothing to how it renders in Firefox, but it makes a difference in IE 5.5+
Here is what I did:
I changed:
var objOverlay = document.createElement(”div”);
to:
var objOverlay = document.createElement(”iframe”);
and I added:
objOverlay.style.filter=’progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=80)’;
to the code within the lines where objOverlay is defined.
The main difference is that Firefox still displays the dark image with 80% opacity, while IE uses a white screen with 80% opacity.
Hope this helps.
opera 7.54 keeps showing the animated loading gif even after he has loaded the big picture.
Thanks for sharing this little gem!
This is cool :) But instead of showing a picture i want to show a small webpage popup. Is this possible ?
the photo-gallery sounds really great. looking forward to it!
I’d like to use this for a flash presentation or some other content, besides images, is it possible now or is it going to be possible some day?
I found that you can add links if you put them within the ‘title’ value.
eg title=”Cannon! Picture by some guy. Visit more here”
then just style the links in the CSS how you want with #lightboxCaption a and #lightboxCaption a:hover
I do love this script.. Although it doesn’t seem to work opera (7.53)
I’ve implemented this script to rave reviews from my site’s visitors. I have links to higher resolution versions of my images as wel las EXIF data in the caption. Future plans are to hook this bit of JavaScript to an AJAX library to allow users to rate these images in the “popup” as well as hook it to some animation effects to fade the whole deal in. Job well done, Lokesh, but this is just the beginning of what’s possible for this script.
On your example page, the top half of the caption cuts off (Firefox 1.5)
first of all, thanks for this!
I have a little problem with IE. I’ve downloaded your files and built a test case … in IE it doesn’t show me the “shadow”.
First of all i don`t understand the usage of the blank.gif, can you tell me what is its use? I coudn’t find a blank.gif on your server too. Maybe you can give me a tip what i’m doing wrong …
* html #overlay{
background-color: #333;/*IE 5 win*/
back\ground-color: transparent;/*IE 6*/
background-image: url(blank.gif);/*IE 5 win*/
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=”overlay.png”, sizingMethod=”scale”); /*All IE ?*/
}
thanks in advance, uli
it’s genious!
Fantastic dude. Fourteen thumbs up.
I love the script, unfortunately I can’t use it anywhere until it is cross browser.. find the bugs and make it work. Thanks for your hard work.
I am trying to get this to work on my blog. i use wordpress and it just won’t take it it seems.
This is a very nice script, I love it and I am using it on my blog at current.
One thing, I dont know alot about javascript; how could I get it to move the lightCaption div ABOVE the image? This is the only thing I really need to make this perfect, thanks.
Hi Lokesh, it seems the CSS does not validate.
Great script!
Anyway to add a onResize event handler to keept centred in a browser window?
best of 2006 already!
thanks,
Andrew
you might want to make your zIndex higher, or have them as user settings, as you’d want the overlay to cover all other dynamic html, such as tooltips and popdown menus.
@ laboratik:
Thanks!! I took your advise and separete all the onlode events to a simple function and now the script is working great combined with moo.fx.
example @ http://dismorfofobico.com/indice.html
I just used this to enhance my Flickr tool “Favourite Photographers”: http://m.ac.nz/c/ - neat addition, I think.
Impressiv!
I`m actually working on a gallery plugin for WordPress (http://www.wildbits.de/mygallery/). Under which conditions can I include parts of your script, Lokesh?
Fantastic script.
I’ve implemented it in the pictures section of our website: (http://www.amberfield.com.au). Works beautifully and adds substantial value.
Thank you.
Brilliant Script! I’m completely loving it.
With regards to the comment about the CSS being invalid: you can place this CSS inside IE conditional comments, which ensures the CSS remains valid while the script still works in IE.
I’ve posted a quick and dirty tutorial about it over on my blog:
CSS Valid Lightbox JS
Thanks so much again for this script Lokesh!
Excellent script, well done to you Lokesh.
I’ve rewritten it a bit and turned it into a GreaseMonkey script for Flickr. I hope it proves useful to someone
Flickrbox.
Okay, I was able to get around the IE form problem by making my drop-down box invisible when the lightbox is up. I did this by first putting the box in a div labled “text2″
then I added this code in the showLightbox function:
var objForm = document.getElementById(’text2′);
This in imgPreload.onload function:
objForm.style.display = ‘none’;
And these two lines in the hideLightbox function:
objForm = document.getElementById(’text2′);
objForm.style.display = ‘block’;
this will make whatever is in the “text2″ div disappear when the lightbox image is open and show back up when it is closed. This may not have been the most eloquent way to do it, but it works.
BTW Lokesh, I really like the script.
The next thing I’d like to figure out is how to add navigation links in the maximized image. That way someone could go to the next or previous large picture without closing and clicking on another thumbnail.
Works great just implemented on a dvelopment site http://petslive.websights.co.uk/productDetails.asp?MainCategoryID=4&subCategoryID=8&productID=153
Anyone had any problems with Safari specifically not closing the enlarged image?
Great job, I love this script.
Thanks, Gerard
Hi!
I stumbled over your site via styleboost.com and checked out your lightbox script, with is very stylish I must say.
I have recently made a simple pictureviewer (http://www.robertvs.com/projects/pic_viewer) and am wondering if I can use some of your css for the darker background effect on my project.
Anyway, cool stuff!
/robertvs.com
This is a super piece. It works great with generating albums. Thanks is not strong enough.
woa i’m stunned. the script is really cool, why didn’t anybody do this before? besides: your website is utterly charming :)
This is a great script, Very useful for portfolios too! Keep improving it, it’s getting better every day :-)
Sorry about another comment, but I forgot to say:
Please keep Opera Browser support in mind! :-)
Thanks.
This script is looking great!
Keep up the good work :)
Anyone having issues on getting this to work with sitemesh and JSP files?
Kagou - There is no way to physically resize the actual image with Javascript. You can only make adjustments with the width and height attributes.
Antonio - I’ve tested w/Opera 8.0 successfully.
bpixel, Mark, Arthos, j - I’m working on it!
Anthony Sangiuliano - Neat idea to use an iframe instead of a div to circumvent the form elements showing through the image in IE. The other solution as others have mentioned is to set the visibility to hidden for problem form elements.
uli - If the shadow is not showing up, make sure the overlay.png is in the right spot.
Roan Lavery - Nice work with the valid CSS.
Gavin Montague - I love it! Flickrbox
any way this could work with an image map?
regardless, it kicks butt.
Ah, I think the problem with the cut-off captions on your example page in firefox is because the image pushes itself down on the apge if it is too near the top and then goes over some of the text… when I’m scrolled all the way up it overrides some of the image text, when I scroll even the slightest bit down, I can see the captions great. I can get screenshots if you don’t see it.
nice..i remember seeing this in most flash site
anyway to do this in actionscript?
Deliscious mate! Been looking for a neat gallery for a long time now and since I just don’t have the knowledge to start coding everything from scratch… -> bookmarked! ;)
Brilliant script! Beautifully presented, coded and very simple to implement, thank you so much :)!
Very nice work Lokesh.
Have you seen the javascript zoom-in photo viewer at Cabel Sasser’s weblog?
This brings a tear to my eye its so lovely!
Thanks for the hard work and free offering!
Cheers.
Fantastic! You should be working for a large company making amazing additions to their website. (If you aren’t already). I’m now using this on my website.
Hi
I’ve added textfilter support for this to the typo blogging software. Have a look at this post for more info.
Thanks much! This is very nice.
Lance
I have nothing to say but what a great idea and the implementation is brilljant!
For some reason, the image wouldn’t load over my flash header, meaning, the swf file was on top of the image, which was on top of the page like usual. What do I do to fix that? I’m sure it’s my bad.
This is so awesome, btw!
Very nice script. I think it’s interesting how it seems to spark the imagination, it’s tempting to ask about “feature X.” I will refrain though, posting it as you have is more than generous. I look forward to seeing where things go from here, thanks.
Brilliant script, I love it I is verry impressed, but… I’m trying to implament it on one of my web sites. And it works perfectly… in Opera 8.01 only. In every other browser I have tried it in it just opens the image in a new page, i.e. the script isn’t used and the image opens like it does by default if you link to another image.
I’m trying to get it working on this site: http://www.photography.xvi32.net/gallery.htm
Note if you check it in IE the PNGs don’t work… yet.
The strange thing is that everyone elses implamentation of Lightbox JS works in all browsers. Why am I special? I don’t want to be special, I want to be normal like everyone else.
I’d love to get this script working proprly as it’s the best thing I have found in a long time.
Cheers
Brilliant script!, saw in on digg a few days back, and now it’s on my blog….
Can’t wait for new features!!
Thanks for the great script!!
Hi, I found your brilliant script on digg a few days ago and worked on implementing it on my new website.
Just one thing I was wondering about is the possibility to make the enlarged image resize to fit the viewers screen automaticly.
could this feature be added easely by myself? or is it something you might add in next versions?
All help welcome :)
And thanks again for the great script!
Great script! I made one minor change you might be interested in… I wanted the code to work differently for people who can’t use it. I have a gallery and if people dont have javascript, I want to send people to a differnet URL that creates an HTML page, rather than display the jpg image directly (as required by your code). What I did was add another attribute to the line called “LIMG” (for Lightbox Image)… and I kept the HREF the way it use to be.
In your javascript, I added:
anchor.setAttribute(”href”,anchor.getAttribute(”limg”));
Inside the loop at the top of “initLightbox”… basically, if your code excutes, it copies “limg” over “href”…. if your code does not execute, the browser ignores limg and loads the default href. Seems to work great so far!
it’s brilliant. thanks!
Excellent script! Eight tentacles up :) Thank you for sharing.
Thank you for your nice and cool script.
I’ve also created similar script based on Lightbox JS.
http://serennz.cool.ne.jp/sb/sp/lightbox/
Love this script! Kudos!
I do have one minor problem. I use iframes and would like image to be viewablein the parent frame, not the iframe itself. Can this be done?
Thanks in advance!
WOW. good stuff..thanks
Excellent script! Very glad I came across it.
I seem to be having the same problem with iframes, however.
I have a site that has images in an iframe within another page. The lightbox will draw in the iframe, and not on the containing page. Is there a workaround for this?
Again, I too am having difficulty with Wordpress- it won’t print the javascript onclick functions…
Is there a way to manually enter them?
Cool
Hey there!
Thx for releasing this nice script. It seeams to me there is still a little bug. If you have no loadingImage this here will not work:
Img: objLoadingImage has no properties
line: 193
I just did a little ‘if’ and it worked again!
Cheers!
Lokesh
Just wanted to say thanks for a cracking script - looking forward to the gallery additions!
Thanks also to Chris of Alien in London for the pointers of where to have each of the files for a Wordress installation.
The script really does make a difference to a blog dedicated to imagery hosted elsewhere as it stops users disappearing to other sites.
Thanks again!
first off: thanks a lot LOKESH, it looks perfect- but you know that!
besides the lightbox.js i have to load another .js which handles full crossbrowser png transparency for img and css-background images.
maybe you can spot on first sight why those two .js’s interfer with each other, but i cant.
http://beachlevel/wp-content/themes/beachlevel/js/lightbox.js
http://beachlevel/wp-content/themes/beachlevel/js/pngiefix.js
maybe you could incorporate the one into the other, because lightbox needs the png alphaimageloader fix anyways…
would be glad to hear from you :)
oops, forgot the .com :D
http://beachlevel.com/wp-content/themes/beachlevel/js/lightbox.js
http://beachlevel.com/wp-content/themes/beachlevel/js/pngiefix.js
Hi,
thanks for the really great script :-) I did some “proof of concept”-Next/Previous Navigation. You can see it at http://www.cronossphere.de/playground/lightbox/
bye bye
Andreas, FYI: sorry, but i dont see any nvigation at all using latest safari
^^ me
Hello,
I have worked on your script to build a slideshow. I read an XML file to get captions and to build previous and next link.
You might find some interest in this script :
http://olivier.ramonat.free.fr/slidebox/
Hi Lokesh
This is a great little script thankyou for making it available for free it really is quite commendable! One small prolem is we cant seemto change the colour of the caption through the stylesheet (well I cant anyways). I can change it by putting a tag in the caption but I thikn you should really be able to do it via the stylesheet or am I missing something?
I like my large images to have a black border with a ligh grey text :-)
Thanks again
Peter
This script is great. Just downloaded the new update from 1/15. There is still an issue with small gap in the overlay in Firefox with the large images. I can’t fix it! Also, the pictures don’t align the same. Some align at the top of page, some align with the middle of the page, some the bottom. The overlay problem could be resolved if all the large images aligned at the top of the page. All in all, this is the best picture script out there. Thank you for offering it.
Sorry, I meant to say the error still exist in IE, not FF.
Hey, awesome lightbox script! My fiance and I are both getting ready to implement it on http://lotus.colodojo.com/ff and http://www.w0lfden.com
it rocks! So neat and stylish, too. keep up the great work.
@ #89 Anonymous
first: thanks for the feedback :) and sorry - this was only a short proof of concept - I tested it in IE6 and FF 1.5 on my Windows machine. I have no Mac yet - so I just cant test it on Safarie. Have you gone left and right beside the Image with the mouse? There should apear some “arrows” to indicate the navigation…
When a picture is clicked on my website the “loading.gif” comes up but the bigger picture never loads….anyone know what the problem may be?
Gud one, planning to implement it in my homepage (http://www.anith.com).
cheers,
Anith
I found out what was making the script work in IE & FF on my web site. It was the image swapping code that was causing lightbox to stop working. If I remove the code then it works, you can see it working here without the code and with out the puddy rollover effect:
http://www.photography.xvi32.net/gallery.html
But as soon as i put the code in to get the image swapping working for the menu the script decides not to work. You can see the rollovers in the menu work but not lightbox here:
http://www.photography.xvi32.net/gallery2.html
So my question is how do I get both the image rollovers and lightbox to play nice together?
P.S. It works perfectly in Opera 8.01, but I spose thats because Opera is a real web browser ;)
Hi, James (#99 and #100)
>So my question is how do I get both the image rollovers and lightbox to play nice together?
My script works in your case.
http://serennz.cool.ne.jp/sb/sp/lightbox/
When you use Lightbox JS, you can add following code at the end of lightbox.js.
==== additional code from here ====
addLoadEvent(function() { MM_preloadImages(’/images/menu01.1home.png’,'/images/menu02.1gallery.png’,'/images/menu03.1about.png’) } );
==== end of additional code ====
And also it is not necessary to set onload handler at your tag.
Regards,
Takkyun
— here from original code —
— end of original code —
Chhers Takkyun! It works great (it’s nearly perfect!) now, thanks so much.
One thing, it’s no biggie just something that I noticed, I’m not sure if it’s a bug or not because it happens in every browser I have stested it in (Opera, IE, FF). When the loading.gif is loaded it’s always displayed (sometimes streched out of shape) on the far right in the middle of the screen. Whats the cause of this, and how can it be fixed?
Cheers,
James
Hi James,
>on the far right in the middle of the screen
I’ve checked it.
Your style.css (text-align at #Content) causes it.
You can fix because of chaging your lightbox.css as follows.
#overlay {
text-align: left;
background-image: url(overlay.png);
}
yes, just add “text-align: left;” for #overlay.
Regards,
takkyun
Hi - lovely script.
Only problem I’m having is that if you’re not using a mouse, once you’ve got to the big image you need to tab through all the links on the page to get back to the big image before pressing Enter and returning to the main page.
Also, once back on the main page I can’t seem to “go anywhere” using the tab button without first clicking the mouse on the page. Is there a way to get round this?
Thanks Takkyun, thanks for your help and support it’s really appreciated.
I still cant get over how xool the script is, I absolutly love it. You and Lokesh should be verry happy and pround your scripts it seems are a huge sucsess and well done because they are great scripts and deserve to be sucsessfull :)
There are a issue in the overlay that happens in most browsers. Is not the big thing but I can’t get fixed:
1.) Restore the Windows where you are looking Lighbox and open a picture clicking in it.
2.) Maximixe the window and take a look at the botton of page: you see that te overlat.png has not grown till the end of page…
Are there some technique to fix this?
Anyway is a great script… thx!
Sorry … in the comment #116 the secuence is wrong: First open the picture with the browser window maximixed and then restore the window without close the picture so you can see at the bottom the efect mencioned.
Great scipt, thanks a lot!
I make a mac style rotating circle loading animation to use with it. You can get it here
http://www.iconaholic.com/images/site-images/loading-mac.gif
(Made especially for Lightbox JS so won’t look good against a light background).
If you resize the /browser/ window from larger to smaller, the document recalculates its height (ie, it becomes taller, but narrower). Your Lightbox JS does not accomodate this; the document breaks out from under your overlay.
This thing Rock’s Nice Idea..
It would be nice to have a fade-in and fade-out effect when the overlay appears: something very fast, ie 1 second… just to have a transition between tehe page and its “dark version”…
Ciao from Italy
Nicola
You are Big time
Nice work, but is there a setting to keep the image fixed in the center of the screen even though you scroll?
Great Script. is there a way to open the popup when the small images are in an imagemap?
Nice script, I’m going to use this on our new site! One thing though, the image popus don’t center correctly when there is a scrollbar involved, could there be a solution for this problem? Can js know whether there is a scrollbar or not?
This is great, I’ve used it on my site.
One thing I noticed is if the target image (the large image) is an animated gif, the image will reappear after closing. The gif frames are still cycling in the background and when it gets back to frame 1, the image pops up again. Either selecting another image real quick or clicking the back button kills it.
Also, it seems the loading.gif is displayed at a fixed size. Where can I change this if I want to use another loading image? Or better yet, allow the image to be displayed in it’s native size, rather than making the script resize it.
Found another bug:
when not using a closing image, the code just doesn’t work. I tried specifying a random image and it also didn’t work, so maybe it has to be an exact size too? Taking out the code around line ~320:
// preload and create close button image
var imgPreloadCloseButton = new Image();
// if close button image found,
imgPreloadCloseButton.onload=function(){
var objCloseButton = document.createElement(”img”);
objCloseButton.src = closeButton;
objCloseButton.setAttribute(’id’,'closeButton’);
objCloseButton.style.position = ‘absolute’;
objCloseButton.style.zIndex = ‘200′;
objCloseButton.style.top = ‘5px’;
objCloseButton.style.right = ‘5px’;
objLink.appendChild(objCloseButton);
return false;
}
imgPreloadCloseButton.src = closeButton;
will get it to work.
Yea, I noticed that Adam.
I just set a transparent gif as the button & that worked fine.
I’m not the first one to tell you: it’s brilliant!
I’ve been trying this before, but you made it a lot easier. No more popups!
Thankyou! This script is wonderful and integrates nicely into my blog :).
I appreciate your time and i’ve bookmarked this site to check back later for updates!
Any chance you can have a mailing list or “subscribe to this thread” idea.
Cheers
I was worrying about the accessibility issues with non-mouse users as I had some difficulty retaining focus on the big image and then once returned to the main page in FF it was impossible to tab anywhere.
I mentioned this on a forum and a forum member was able to come up with a solution to enable smooth keyboard use too - have a look at the thread to see the solution:
http://www.csscreator.com/css-forum/sutra79112.html#79112
I have made a version of lightbox with next/previous buttons. Take a look:
http://www.basementmedia.no/blogg.php?id=292
My trick is to make two javascript-arrays with all the addresses and captions and get lightbox.js to fetch the information from there in addition to have it in the ‘href’ and ‘title’ attributes.
My modified lightbox.js:
http://www.basementmedia.no/mms/lightbox.js
I addition to the two arrays (one for image addresses, “ImagesArray”, and one for captions, “CaptionsArray”), you need to write the link (a href) code like this:
a href=’http://www.a.com/a03.jpg’ rel=’lightbox’ title=’A cool image.’ imageNumber=’3′ imageMax=’11′
imageNumber is the number of the current image you want to open (first image is ‘0′, second is ‘1′). imageMax is the number of images in the gallery.
Hi,
What would need to be changed to use the title attribute o fthe image, not the link, as teh caption?
I want to use this script but my boss wants the title attribute in the image, not the link. Any suggestions?
Great script!
I didn’t really have a use for it to display pictures, but I was able to tweak it so that I could display editable fields to a user without having then have to go to a new page or open a popup window. It works fantastic with some extra javascript and a dash of AJAX goodness!
Looks Fantastic
But I can’t get it to work in my simple example ;-( Anyone help?
Is there more to do than DL the files, throw them into the images folder and then do steps 1 & 2?
I get no overlay or image. If I include the lightbox.css I get the overlay, but still no image!
lightbox is great. got it working on my site (http://www.zealivityfive.com) and i’m loving it. linked you back as well.
Great Script!
But after I upgraded to the latest version (I first installed it on Jan 5th), it doesn’t load image(Firefox), or cause JS error(IE). What’s wrong?
my page is
http://www.matsubarafamily.com/lab/item/87
I found a solution.
around line 196 of lightbox.js, I changed
objLoadingImage.style.display = ‘none’;
to
if (objLoadingImage) {
objLoadingImage.style.display = ‘none’;
}
And everything seems to work fine (except that I still cannot find close button)
Incredible Script! Thank you for sharing!
LOVE this script. it’s made my photo page for my newborn son 100 times better! Thanks so much, and keep up the great work. I’ll be checking back often!
this is an awesome script. i’m having problems with it in safari and explorer though. It works great in firefox but in the other two browsers when I click my pic it just opens the linked file.
this is cool! never knew javascript can do such superb stuff.
anybody know why it didn’t work for my IE 6? it opens the link file in a new blank page.
Hi
very nice - has a problem if there is already onLoad code in the BODY tag - fails to work
What does it write to preload images?
I had to include the lightbox.js after the BODY tag, otherwise it didn’t detect my existing onload function.
Nice little script you’ve got here!
#120 Chestah
RSS feed!
#121 HellsBells
I’ve just finished adding a keypress action for closing the Lightbox.
Lokesh,
As if you haven’t heard it enough… smooth work ;)
What is needed to display a .swf or .mov in the lightbox overlay space instead of a still image format?
a very elegant solution to the pop-up window problem/annoyance.
i changed it to use the rev tag for the caption. that way i could put html in the tag and ff or ie won’t display everything in the title/tool tip pop-up
thanks.
Hi,
great job!
But I found a little bug: (browser: firefox 1.5 and IE 6) when you try close image by pressing key other than defined (e.g. space instead ‘x’) then image is hidden but page still exists in overlay mode. I hope it will be fixed in next release.
greeting from Poland
eMPa
TO EVERYONE USING IMAGE-MAPS
You CAN use them, and it IS an easy fix.
In the lightbox.js file, find the line:
var anchors = document.getElementsByTagName(”a”)
and change it to
var anchors = document.getElementsByTagName(”area”)
then place “rel=lightbox” in all your area tags for the map
needless to say, you’ll need a seperate .js file if you want to still maintain “normal” functionality
#138 JC
Can you elaborate? I’m rather slow with this stuff. Perhaps an example or a link to your implementation. Your change is just what I need. Thanks in advance.
Hi,
nice script !!!
I have a question : is it possible insted of that “hit X to close” one can have hit any key to close ?
Thanks !
K
Great Script…..Is anyone else experiencing a problem in IE with the script the ‘first’ time it is loaded. It never seems to work the first time, but then when I try again in IE, it works perfectly. When I close the window, start again, same thing…..problem only on the first thumbnail I click. After that, smoothe sailing. If someone else has experienced this, please let me know how you fixed it.
dreamweaver8484 at yahoo dot com
#143 ND –
I believe the problem is when you have a page that is not fully loaded. For example, I have several “albums” with 100+ thumbnails that need to load… when I’m not patient, the effect does not happen. When I am — and all elements of the page have loaded, then the script does work. I have no idea why, but I notice this on *every* browser.
#144 Jason
Thanks for the response. What happens is the picture loads the old fashioned way, without the lightbox effect. I have to click the back button to make it work the second time. I don’t think it is the page not loading…..thanks anyways.
I don’t think you understood my explanation, as the problem you describe is exactly what I too get and why… Try going to any page of thumbnails you have, and instead of clicking on one right away, wait … let’s be extreme… wait 3 full minutes. Then try clicking one of your thumbnails. I bet it works the first time.
J
oops… #146 was me :-p
Thanks Jason….I will give it a try and wait a few more seconds. If you are correct, then it should not be a problem since visitors will read through my site first, giving plenty of load time. Thanks.
It doesn’t work under Opera. Actually it’s not that it never works, it doesn’t work every time.
It is stuck under Opera, the loading gif stays on top, and the real picture is nowhere.
If I close down the loading gif, (or refresh the page) and click again, the real picture comes in instantly.
I think the error is in preloading images.(maybe if its in multiple div-s or whatever)
Does anyone have some advice?
Works fine in Opera 8.5.1 Mac for me.
MightyDuck #149
I just tested it in Opera, and had the same problem.
ND
Look at: http://www.fot-online.hu
It’s a hungariaan page. The interesting thing is the at little news’s images. They are in multiple div-s, and than in a table.
And doesn’t work. (But work on this page (http://www.lokeshdhakar.com/2006/01/10/lightbox-js)
But as I see, not I am the only one who had some prblems with it.
The keypress doesn’t close the overlay PNG in safari (2.0), only mouse click does that.
Nicely done sir! A great bit of JS.
I have only question; Is there a way to stop a vertical page scroll bar appearing when the window is displayed?
Elegant is the word! I have begun implementing this lovely script on a site I am currently building. I did get the it to work fairly easily, but when I went to add a Javascript drop down menu in Dreamweaver (*blush), nothing worked… well.. I did get it to work a little, but pretty soon the code was a horrific mess. What can I say? I don’t know how to do it yet. ;-p
I’ve spent two or three days working on this, and finally have come back here to ask…: Is anyone on this lovely blog willing to show/demo/tell those of us who are code illiterate just how to implement this sweet script along with a simple drop down menu that works off a sliced image? Gosh that would sure be great! I’d also love to add an image rollover script too… haha. Would this be possible?
thanks Lokesh!
So like, I think I found a “bug”… It doesn’t overlay flash! :/
sorry for the commentspam and sorry for the flash-thingy, I was too damned lazy to search this iste for “flash” :D
Whenever I try loading my page in IE, it gives me this error:
Line:218
Char:3
Code:0
Error:’navigator.PRXappVersion’ is null or not an object
I try everyone else’s script and their implementation seems to work fine. Anyone experienced this error?
Lokesh
Love the script it has given my site a better look and feel, but I have problem with I.E.
My site works fine within firefox but not I.E., the page with the image on it has the image in a nested table and this works fine in firefox producing the desired effect, but in i.e. all it does is just link to the image it doesnt even put the image as an overlay, i know its a long shot without seeing the html but can you think of any reason for this or a way round it.
Regards
Glen
can you tell me, how add google adsense code below the enlarged image?
thanks, :)
Thanks for lightbox!
It really is a great tool and can improve the usability of your website a lot. I use it on my website which is mainly about the Python programming language. See how I use it here:
http://www.serpia.org/spe
please add a comment if you like!
thanks,
Dimitri
Love the new close button feature, what i would like to do with this script is to be able to change it from displaying an img to displaying an iframe where i can put a flash animation or a page of html whatever. But to still also do the image thing too, i expect to have to add in extra attributes and the like.
My skills in javascript are really up to speed, i have tried changing…
var objImage = document.createElement(”img”);
–to–
var objImage = document.createElement(”iframe”);
and adding in extra attributes etc
i have also tried changing the…
var objLightbox = document.createElement(”div”);
–to–
var objLightbox = document.createElement(”iframe”);
but to no effect.
Does anyone have any suggestions, or something that can point me in the right direction
Regards,
Andy
Hi,
Very nice improvements in this version, great work!
About Opera:
-Works a treat in 8.01 on Mac OS X.
-Works a treat in Opera 8.51 on Linux (Ubuntu flavour).
-Very buggy in Opera 7.54 Windows XP, just displaying the overlay and loading img if present. Works sometimes on single image in a page, but refuses to work on another page with exactly similar markup. Go figure…
-Works a treat with Opera 8.51 on Windows XP.
Other browsers:
- Icab 3.0.0 close with “x” on keyboard doesn’t work but all the rest is fine.
It is definitely a great cross-browser script :-)
Keep on the good work…
Regarding IMAGE MAPS and Jason Buechler solution….
1 problem, there is no rel attribute in the area tag… so instead, use alt=”lightbox”
Here is the process again:
In the lightbox.js file, find the line:
var anchors = document.getElementsByTagName(?a?)
and change it to
var anchors = document.getElementsByTagName(?area?)
then, find:
(”rel”) == “lightbox”)
and change it to
(”alt”) == “lightbox”)
This will validate as XHTML