[thelist] setAttribute(someevent) in IE?

sbeam sbeam at syxyz.net
Tue Jun 1 21:49:45 CDT 2004


On Tuesday 01 June 2004 03:12 pm, liorean wrote:
> Yeah - so call that function from within this function, then. Nothing
> prevents you from doing
>
>     document.getElementById('thelink').onclick=function(e){
>         e=e||window.event;
>         foo(arg1,arg2,arg3,...,arg8362);
>     };

ahhhh thanks, I had a 'new' before 'function' - this causes the function 
contents to be executed at compile time... was messing me up. Guess I 
dont understand that 100% - the 'new' makes it a an object definition 
which works like eval()? Anyway, take out the 'new' and it works. Here 
is what I came up with:

===
op = 'something';
linkObj = document.getElementById('thelink');
linkObj.onclick = function (e) { foo (e, op) }

function foo(e, param) {
    e = e || window.event;
    elem = (e.target) ? e.target : e.srcElement;
    // can use elem and params here normally
    alert(elem.id+':'+ param);
}
===

thanks to all!

-- 

# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/


More information about the thelist mailing list