I have a <select>
tag containing one <option>
element:
<select id="someselect"> <option value="2">B</option> </select>
A single <option>
later replaced with jQuery. The new parameter list always contains the old option:
selected = $('#someselect').val(); $('#someselect').html('<option value="1">A</option><option value="2">B</option>').val(selected);
This works as expected. However, when we go from a webpage to Google Chrome and click the back button, something strange happens. The select tag returns to its original state (it makes sense), but the only <option>
element is not selected!
What is the reason for this behavior in Chrome?
I created a minimal working example: http://dl.dropbox.com/u/27566470/backdemo.html
Initially, there is only one <option>
. First click "click" to replace the parameters (but keep the parameter "B"), then click "Google" to go from it, and then use the "Back" button in Chrome to see the <select>
tag with only one that doesn't selected.
Edit: Clarify, I'm not interested in how to fix this. I'm curious why Chrome works this way. Serving the original (unmodified) DOM after using the "Back" button makes sense, but why is the only option chosen?
Intru source share