I have some javascript that on page load reads a group of check boxes checking their checked status. If the checkbox is checked then a value is added to an array which is later used.
var _chkBoxes = d开发者_如何转开发ocument.getElementsByName("chkProduct");
var _chkBoxesLen = _chkBoxes.length;
var _chkArray = [];
for (var i = 0; i < _chkBoxesLen; i++) {
if (_chkBoxes[i].checked === true) {
_chkArray.push(_chkBoxes[i].id.split("-")[1]);
console.log(_chkArray);
}
}
This works fine for all browsers when the page is freshly loaded.
However in IE if a user ticks some boxes, navigates to another page then pushes the back button then this work does not recognise that checkboxes have been previously checked, even though on the page they are.
Is this a bug with IE and whats the fix, any opinions appreciated!
This is a feature in the browser, and other browsers than IE does this in a similar way, so the problem is most likely not isolated to IE.
When you go back, the browser loads the page and then automatically fills the form with the previous data. You have to make sure that the script runs after the browser has added the data to the form, or it won't notice the change.
精彩评论