-
Another reason why I hate Internet Explorer.
All new browsers tend to cache form values. Nothing unusual up to here, a little annoying, but not unusual.
We have the following example:
1<select id="select"> 2 <option value=a>a</option> 3 <option value=b>b</option> 4 <option value=c>c</option> 5</select> 6<script> 7 8var checkSelected = function () { 9 var element = document.getElementById('select'); 10 alert(element[element.selectedIndex].value); 11} 12 13// run after onload 14window.onload = checkSelected; 15 16// run before onload 17checkSelected(); 18 19</script>
Load the page, select the third value and then refresh. Because no form was submitted the first impression is that the result will always be “a”. It seems it’s not really like that:
- FireFox: c c
- Google Chrome: a a
- Internet Explorer: a c
I can understand why FireFox choose to cache the values even when no form was submitted.
I can understand Google Chrome for not caching the page if the form was not submitted.
But Internet Explorer caches the values and them loads them only after the page was loaded? This is confusing to me! I mean you don’t have the option of not using onload? Not even if the form was not submitted?
This test was made on Internet Explorer 9 and compatibility view to versions 7 and 8.