Posts tagged with Prototype

Loading Javascript Libraries When Needed

June 23rd, 2008

Here is a nice little Javascript function to load some Javascript libraries:

function includeLibs()
{
var libs = [{object: 'Prototype', src: 'http://www.mobypicture.com/slideshow/prototype.js'}, {object: 'Lightbox', src: 'http://www.mobypicture.com/slideshow/lightbox.js'}];
for (var k = 0; k < libs.length; k++)
{
try
{
var obj = eval(libs[k].object);
}
catch (err)
{
var obj = false;
}
if (obj == false)
{
var newjs=document.createElement(’script’);
newjs.type=’text/javascript’;
newjs.src=libs[k].src;
document.getElementsByTagName(’head’)[0].appendChild(newjs);
}
}
}

This is particularly useful if you’re writing a widget that requires external libraries but the user might already have them loaded, such as Prototype.

Multilink

June 21st, 2008

Multilink is a very simple Javascript library that creates tooltips with multiple links per ‘normal’ link, its simplicity due to Prototip2 and Prototype. Why have one link when you can have ten! Check out the Multilink page for an example.