I've a strange situation on IE 9. It just works in Chrome and Firefox. I will post only the relevant code.
It's a legacy application (VS2008). The "corp framework" defines field masks at runtime, it uses the onkeyup event, with javascript like this:
Javascript:
function mascara(o, f) {
v_obj = o
v_fun = f
setTimeout(function() {
v_obj.value = v_fun(v_obj.value)
}, 1)
}
ASP.NET HTML:
<asp:TextBox runat="server" ID="TextBox5" AutoPostBack="true" OnTextChanged="TextChanged" />
The mask and the postback event works in all browsers except IE9. When I remove the setTimeout in the javascript mask function, the postback works, but i lost the mask behavior.
I figure out that AutoPostBack=true will render the onchange event with setTimeout. The mask uses another time the setTimeout function, when I remove the setTimeout in the mask, the postback works at IE 9.
Rendered HTML:
<input name="TextBox5" type="text" onchange="javascript:setTimeout('__doPostBack(\'MPTextBox5\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="MPTextBox5" onkeyup="mascara(this, mnum);">
I can't figure out what is the problem at IE9 and the solution.
MS will not fix this bug:
Workaround found at: http://bugs.jquery.com/ticket/10818
// Set value for IE without clearing the "changed" flag
this.innerText = val;
// Set value for everyone else
if ( this.value != val ) {
this.value = val;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.