Later, ...">

Is this a bug in IE9 Beta?

I have something like this in my web forms:

<input type="hidden" name="myField" value="defaultValue" />

Later, in some Javascript, I rewrite the default value before sending the page to the server.

var formField = document.getElementsByName("myField")[0];
formField.setAttribute("value", "myNewValue");
var form = document.getElementById("myForm"); 
form.submit();

All browsers (I tested this code for several years in IE5-IE8, Firefox, Opera, Chrome, Safari, ...) send to the server "myNewValue". Except for IE9: it sends a "defaultValue". What's going on here? Am I missing something?

If I remove the value attribute from the field, it also works in IE9. It also works in IE9 if I switch to IE8 rendering mode.

Is this a bug or is IE9 more standard than other browsers?

+3
source share
2 answers

HTML4, , , HTML5 , . . : ( )

content value . content value , , - false, , , , , .

. http://dev.w3.org/html5/spec/the-input-element.html#attr-input-value

, setAttribute, , setAttribute value myNewValue defaultValue.

, , IE9 Beta.

0

value .

, , .

, , , , , , , .

value setAttribute.

+2

Source: https://habr.com/ru/post/1766605/


All Articles