[Javascript] IE attachEvent question

David Dorward david at dorward.me.uk
Fri Oct 17 10:07:03 CDT 2008


John Warner wrote:
> First the target for this is IE only and anyone who sees this via the
> intranet with another browser, we don't care.
Wasn't it IBM who scrapped a plan to switch their desktops to a cheaper
alternative when it became clear bits of their Intranet (written years
earlier when they thought they'd use Windows forever) depended on IE and
rewriting everything after the fact would inflate the cost dramatically?
(Hint, hint).

Use a library (like YUI or JQuery) to attach your events - they do all
the heavy lifting to normalise between browsers.

>  My question I want to
> simplify a bit of  client code on a page that gets loaded. To keep
> everything separate we have been using attachEvent to add onFocus events to
> several controls. The question is, is there anyway I can pass a parameter
> to the event code itself. I noticed several of the events are basically the
> same code except for determining the html tag. I'd like to just pass the
> control to the event handler and then just fire the code and reuse that
> function. Can anyone help here? 
Generate the function using a closure.

http://developer.mozilla.org/en/A_re-introduction_to_JavaScript#Closures


-- 
David Dorward
http://dorward.me.uk/




More information about the Javascript mailing list