To display the Properties of an element. This is very useful function to know what all the properties are exist (can be selected) on given element.
function displayProperties(ele){
var prop = "";
for(att in ele){
prop += att + "::"+ ele[att] +"\n";
}
alert(prop);
}The output would be :
language::
scrollHeight::18
isTextEdit::true
currentStyle::[object]
document::[object]
onmouseup::null
oncontextmenu::null
isMultiLine::false
clientHeight::18
onrowexit::null
onbeforepaste::null
onactivate::null
scrollLeft::0
lang::
onmousemove::null
onmove::null
onselectstart::null
parentTextEdit::[object]
oncontrolselect::null
canHaveHTML::false
onkeypress::null
oncut::null
onrowenter::null
onmousedown::null
onpaste::null
className::
id::Country Name
onreadystatechange::null
onbeforedeactivate::null
hideFocus::false
dir::
etc...
Events can be attached to an element dynamically.
window.attachEvent('onload', function() { showBtn(formName, eleName); });
The above snippet would append the event to window. If there is any existing onload functions then it would call them first and later it will call above function (i.e. showBtn()).