View Full Version : lightbox without a link

01-10-2008, 11:35 PM
1) Script Title: Lightbox image viewer 2.03a

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm

3) Describe problem: extend functionality

Is it possible to modify this lightbox code (or any lightbox code, for that matter) so that the lightbox effect can be evoked without the usual "href" link tag? Using something else like onclick on an image tag, for example?

01-11-2008, 06:09 AM
Yes, that probably could be done with a bit of modification of the lightbox script, probably more than just a little bit. However, I see no reason to. If you want lightbox activated onclick of an image, you may do this:

<a href="some.jpg" rel="lightbox" title="Some Picture"><img
src="some_thumb.jpg" style="border:none;"></a>

Incidentally, if you happen to have an image map, lightbox can initialize on an area tag as well:

<area rel="lightbox" shape="rect" coords="0, 22, 30, 60" href="some.jpg" title="Some Picture">

So an href link is not required, but an href link or an href area tag is.

This is actually an accessibility feature for search engines indexing your site, as well as for users who have javascript disabled.

01-11-2008, 04:36 PM
Thank you, Supreme Allied Coder. I just need to implement a lightbox-style effect on images which cannot have "a href" links around them, because that would mess up other things. Accessibility isn't really an issue in this particular case, and I can't introduce imagemaps.

Anyhoo, it's nice to know it's possible, though...!

01-11-2008, 05:02 PM
I would consider working out the modifications, or finding a more suitable script for you if I knew exactly why. That often makes a big difference in how the code would need to work. Also, I'm still not convinced this is necessary. Regardless of whether or not a link is present, the images (if they can be seen at all) can still be directly navigated to. If it is a problem with another script editing/modifying all href links (or just lightbox links plus its own links) on a page, and thus messing up lightbox, that other script could probably more easily be made to exclude rel="lightbox" links than one could edit lightbox itself for this purpose.

07-03-2009, 06:00 PM
The problem is that some users will want to use Lightbox within a CMS wysiwyg. For example FCKeditor.

If the image icon is encased within a <a href: ..etc></a>, the online editor will not consider it an image but a link... which has its own set of functions and panels. If we could evoke lightbox from an onclick() then this could happen within the image tag and therfore still be subject to the image controls of the wysiwyg.

Please let me know if an onclick exists as I would like to incorporate ligthbox within my own wysiwyg.

Kind regards

Abiel M de Groot.