[thelist] [JavaScript] IE: attaching events to generated content

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Wed Jan 17 21:01:48 CST 2007


Hi Paul,

The easiest way is

element.onevent = fncEventHandler approach;

it is cross-browser (and old fashioned) and always work.

Otherwise you need a cross browser wrapper.
Almost all of the JavaScript libraries out there have some kind of
addEventListener function to make this easier.

the below is copied and modified from s at rdalya:

            if(_.defined(obj.addEventListener))
            {
                obj.addEventListener(eventType,fncEventListener,false);
            }
            else if(_.defined(obj.attachEvent))
            {
                obj.attachEvent("on"+eventType,fncEventListener);
            }
            else
            {
                alert("ERROR: unknown event handler: " + eventType);
            }

btw I've open-sourced s at rdalya.
I will load the recent stable version to sourceforge servers and
continue my development there. Currently the page is rather empty.

https://sourceforge.net/projects/sardalya

Everyone is welcome to participate.

Cheers,
-- 
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/cre8/blog/
+> Going solo in Turkish: http://www.volkanozcelik.com/donkisot/
+> My projects/studies/trials/errors : http://www.sarmal.com/
+> Sardalya JavaScript Library: http://www.sarmal.com/sardalya/



More information about the thelist mailing list