Re: Dynamically created select not firing events in IE, works in other browses
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Sun, 22 Jul 2007 15:19:39 -0400
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/
.
- Follow-Ups:
- References:
- Prev by Date: 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: 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