26 Nov 2010

Simple Jquery Lightbox

Wrote some code that I didn't end up using, but it's a shame to bin it :)

Simple lightbox using Jquery UI dialog widget:

function LightBox(imgSrc, imgTitle)
{
var img = $('<img />');
$('body').append(img);
img.attr('src', imgSrc);
img.load(function()
{
var lightBox = $('<div></div>');
lightBox.dialog({ autoOpen: false, height: img.height() + 50, width: img.width() + 50, modal: true, title : imgTitle });
lightBox.html('').append(img);
lightBox.dialog('open');
});
};

No comments:

Post a Comment

Comments are very welcome but are moderated to prevent spam.

If I helped you out today, you can buy me a beer below. Cheers!