[SolvedJS: use reference to function (with param(s)) as para
Posted: Mon Apr 03, 2006 3:59 pm
Hi, i'm playing with a bit of JavaScript...
The problem is that the second addEvent doesn't seem to work.. So i wonder how i can pass a reference to the change function (with it's parameter).
Code: Select all
function addEvent(obj, evType, fn) {
if (obj.addEventListener) {
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent) {
return obj.attachEvent('on' + evType, fn);
} else {
return false;
}
}
function change(element){
var e = document.getElementById(element);
if (e.style.display == 'none') {
e.style.display = '';
} else {
e.style.display = 'none';
}
}
function hide(){
document.getElementById('pageoptions').style.display = 'none';
}
addEvent(window, 'load', hide);
addEvent(document.getElementById('pageoptionsbutton'), 'change', change('pageoptions'));