PDA

View Full Version : :: Lightbox image viewer 2.03a - remove hover title



katebellami
08-09-2011, 02:02 AM
1) Script Title: :: Lightbox image viewer 2.03a

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

3) Describe problem: I would like to have captions on my lightbox slides, but if I designate a 'title' it also shows up when I hover the the link. Can I prevent the hover function? It looks weird and distracting on the site I am using this for.

jscheuer1
08-09-2011, 04:34 AM
Using a plain test editor like NotePad, edit the lightbox.js file. Around line number 361 you will find:


function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
var ddimageTitle=anchor.getAttribute('title')
var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
};

Replace it with:


function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
var ddimageTitle=anchor.getAttribute('data-title')
var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
};

And save. Use that version of the script. Now, instead of the title attribute of the link:


<a href="some.jpg" title="my caption" rel="lightbox">Whatever</a>

do:


<a href="some.jpg" data-title="my caption" rel="lightbox">Whatever</a>

Notes:


You may have to refresh the page and/or clear the browser cache in order to see the effects of these changes.


This will work on a page with any standards invoking DOCTYPE. But it's only w3c valid for an HTML 5 DOCTYPE.

katebellami
08-09-2011, 02:29 PM
Brilliant - this worked perfectly. Much appreciated!!!