Question

I was testing my existing code in different browsers and following code is working fine in IE 8,9, Firefox. But it does not seem to work in IE 11. What change will be required?

 <html:select multiple="true" property="sourceList" size="15" style="width:70px"
onchange="listSelectionChanged(this);" >

and

 function listSelectionChanged( list){
alert("list length = " + list.value.length );
alert("list is " + list.value);

// some code stuff here
}

The problem that i am facing is that in all the other browsers except IE 11, i am getting the alerts as expected with the correct length. In case of IE 11 , when i use keyboard keys to select the content i get the right result but when i use mouse click to select the content, i do not get any alerts. If i use onmousedown instead of onchange, i get alert but the length is 0 and value is null.

EDIT:

Client Side Code:

<select name="sourceList" multiple="multiple" size="15"
onchange="listSelectionChanged(this, 'addLine');" style="width:70px">
<option value="1:0:0">1:0:0</option>
<option value="1:0:1">1:0:1</option>
<option value="1:0:2">1:0:2</option>
<option value="1:0:3">1:0:3</option>
<option value="1:0:4">1:0:4</option></select>

Just mentioning, length will come as 5 in other browsers.

Était-ce utile?

La solution

Though i could not fix the absurd behavior of onBlur event on Safari, but i found a simple workaround that might help someone who is also facing the same issue. In addition to firing the alert of wrong input, i also changed the value to 0(default) in case invalid field is entered. This way the focus is reset and infinite loop is avoided.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top