Monday, January 8, 2007

Cross-Browser getElementById()

A useful Javascript function to return the ID of an element that is supposed to work on most browsers.Thanks Netlobo.com! :)

function returnObjById( id )
{
if (document.getElementById)
var returnVar = document.getElementById(id);
else if (document.all)
var returnVar = document.all[id];
else if (document.layers)
var returnVar = document.layers[id];
return returnVar;
}

No comments: