Re: firefox and problems with getElementById
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: firefox and problems with getElementById

From: Martin Honnen <mahotrash@yahoo.de>
Date: Wed Nov 30 2005 - 20:00:13 CET

Andrea wrote:

> <form>
> <span id="write_html"></span>
> <button onclick="new_html();">Display html</button>

The problem is that button, according to the HTML 4 specification the
default for the button type is submit so with a conforming browser like
Mozilla the button executes the onclick handler and then submits the
form, with no action attribute set that means the page is reloaded.
   <http://www.w3.org/TR/html4/interact/forms.html#h-17.5>
IE has its own rules about the default and makes it a simple click
button so in your example only the script is executed:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/button.asp>
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/type_3.asp>

Use
   <button type="button"
or even
   <input type="button"
to get the same behavior in browsers.

-- 
	Martin Honnen
	http://JavaScript.FAQTs.com/
Received on Sat Dec 3 04:33:52 2005