W
windandwaves
Hi Folk
I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:
function getObj(name) {
if (document.getElementById){
if(document.getElementById(name)) {
if(document.getElementById(name).style) {
this.obj document.getElementById(name);
this.style document.getElementById(name);
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}
I guess that it finds out how the browser refers to elements with a specific
IDs and then returns them. However, I dont really understand "this." other
than that it refers to the function itself and how it or what it returns.
can someone explain it?
TIA
- Nicolaas
I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:
function getObj(name) {
if (document.getElementById){
if(document.getElementById(name)) {
if(document.getElementById(name).style) {
this.obj document.getElementById(name);
this.style document.getElementById(name);
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}
I guess that it finds out how the browser refers to elements with a specific
IDs and then returns them. However, I dont really understand "this." other
than that it refers to the function itself and how it or what it returns.
can someone explain it?
TIA
- Nicolaas