PDA

View Full Version : Lightbox Help Onmouseover



frank95a
08-07-2008, 08:02 AM
1) Script Title: Lightbox V 2.0.4

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

3) Describe problem: Simply put, is there anyway to have the image viewer window open onmouseover rather than onclick? If I use rel="lightbox" , then I have to click on the image for the viewer to open. I would rather need the image to open onmouseover

Thanks in advance

rangana
08-07-2008, 12:35 PM
Go to lightbox.js. Find this part (found in lightbox.prototype):


Lightbox.prototype = {

// initialize()
// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for
// 'lightbox' references and applies onclick events to appropriate links. The 2nd section of
// the function inserts html at the bottom of the page which is used to display the shadow
// overlay and the image container.
//
initialize: function() {
if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName('a');
var areas = document.getElementsByTagName('area');

// loop through all anchor tags
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];

var relAttribute = String(anchor.getAttribute('rel'));

// use the string.match() method to catch 'lightbox' references in the rel attribute
if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
anchor.onclick = function () {myLightbox.start(this); return false;}
}
}


Change highlighted with onmouseover instead and see if that helps.

frank95a
08-07-2008, 03:11 PM
Thanks so much... It worked like a charm