checkbox issue in IE9
I'm running into an issue my website using google maps API v3 works fine in chrome but I am having a checkbox issue in ie. When I click on my checkbox to load layers everything works but refreshing the website cause the layers to clear (which is fine) but the checkboxes stay checked. is there a way开发者_如何学C to force the checkboxes to clear instead of telling my users to do control f5. http://gbnrtc.services.officelive.com/default.HTML thanks K
It seems like IE9 preserves checkbox state. To get around this, explicitly set your checkboxes to be cleared. You can do this with the following function:
function clearAllCheckboxes() {
// Find all <input> elements.
var elems = document.getElementsByTagName("input");
// For each <input> element which is a checkbox, clear it.
for (var i = 0; i < elems.length; ++i) {
if (elems[i].type == "checkbox") elems[i].checked = false;
}
}
Call this function when your page first loads, and it will clear all checkboxes.
I can't help but feel that there is an easier solution, but the syntax of checkboxes makes it hard. Specifically, setting checked to anything in HTML (even "false") will cause the checkbox to be checked.
精彩评论