Re: Dynamically created select not firing events in IE, works in other browses
- From: tapuleo <tapuleo@xxxxxxxxx>
- Date: Sun, 22 Jul 2007 12:29:47 -0700
On Jul 22, 12:19 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
tapuleo said the following on 7/22/2007 3:08 PM:
I'm creating a select tag, with options on the fly, and the events
(onclick, onchange, onkeydown) are not firing at all in Internet
Explorer. I tried IE 6 and 7...no luck. This all works fine in
Firefox.
Is there some trick to getting this to work in IE? Here's a short
example. If you click the button, the select (listbox) appears, but
no events fire.
------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Why are you trying to get IE to parse a document that it inherently
doesn't recognize? Use HTML4.01 strict and forget XHTML.
sel.setAttribute("id","wsrListBox");
sel.setAttribute("size","10");
sel.id = "wsrListBox"
sel.size = 10;
// try to set event ***NEVER FIRES in IE***
sel.setAttribute("onclick","alert(1);");
sel.onclick = function() { alert(1)};
setAttribute is known to be buggy in IE.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Perfect-o. sel.onclick did the trick.
Thanks!
.
- References:
- Prev by Date: Re: Dynamically created select not firing events in IE, works in other browses
- Next by Date: Re: Dynamically created select not firing events in IE, works in other browses
- Previous by thread: Re: Dynamically created select not firing events in IE, works in other browses
- Next by thread: Re: Dynamically created select not firing events in IE, works in other browses
- Index(es):
Loading