简体   繁体   English

使用Windows 7 Professional而不是Windows 7企业版的IE9中的Javascript问题

[英]Javascript issue in IE9 with Windows 7 Professional and not in Windows 7 Enterprise

  1. Is it possible to get a javascript related error only in IE9 with Windows 7 Professional and not in IE9 with Windows Enterprise? 是否有可能仅在使用Windows 7 Professional的IE9中获取与javascript相关的错误,而不是在使用Windows Enterprise的IE9中?
  2. Can there be any difference in the way IE9 behaves with respect to javascript between a 32-bit Windows 7 and a 64-bit Windows 7? IE9在32位Windows 7和64位Windows 7之间的行为方式有何不同?

Please help me with this. 请帮我解决一下这个。 The full javascript function is below. 完整的JavaScript功能如下。

function foo() {
    var isChecked = false;
    var checkBoxField = "MyCheckBox1";
    for(j=0;j<document.forms[0].elements.length;j++) {
        if(document.forms[0].elements[j].name.search(checkBoxField) == 0) {
            if (document.forms[0].elements[j].checked == true) { 
                isChecked = true;
            }
        }
    }
    alert(isChecked);
}

The isChecked variable has to be true when the checkBoxField is checked. 选中checkBoxField时,isChecked变量必须为true。 It is true in IE9-Windows 7 Enterprise Edition (Not sure about 32-bit or 64-bit) and it is false in IE9-Windows 7 Professional Edition (32-bit) 在IE9-Windows 7企业版中确实如此 (不确定32位或64位) 在IE9-Windows 7专业版 (32位)中是错误的

Apologies. 道歉。 After looking at the IE settings in the exact machine where the issue occurs, it is clear that it is due to caching. 在发现问题的确切机器中查看IE设置后,很明显它是由缓存引起的。 The setting Preserve Favorites website data preserves the old js file and is not downloading the updated version (even if we try to clear cookies, history, temporary files etc). 设置保留收藏夹网站数据保留旧的js文件,并且不下载更新的版本(即使我们尝试清除cookie,历史记录,临时文件等)。 Once that setting is unchecked - history, cache cleared everything started working. 一旦取消选中该设置 - 历史记录,缓存清除一切开始工作。 Cheers, 干杯,

Apologies. 道歉。 After looking at the IE settings in the exact machine where the issue occurs, it is clear that it is due to caching. 在发现问题的确切机器中查看IE设置后,很明显它是由缓存引起的。 The setting Preserve Favorites website data preserves the old js file and is not downloading the updated version (even if we try to clear cookies, history, temporary files etc). 设置保留收藏夹网站数据保留旧的js文件,并且不下载更新的版本(即使我们尝试清除cookie,历史记录,临时文件等)。 Once that setting is unchecked - history, cache cleared everything started working 一旦取消选中该设置 - 历史记录,缓存清除一切开始工作

There shouldn't be any difference in different windows version, since most time you'll be using 32 bit ie. 不同的Windows版本应该没有任何区别,因为大多数时候你会使用32位即。 But you never know what kinda of bug is in ie javascript 但你永远不知道javascript中有什么样的bug

what you can try is is use jquery you code looks like 你可以尝试的是使用你的代码看起来像jquery

function foo() {
    var isChecked = $("name='MyCheckBox1':first").attr('checked');      
    alert(isChecked);
}

set your checkbox id to MyCheckBox1 and it further simplifies 将您的复选框ID设置为MyCheckBox1,它进一步简化了

function foo() {
    var isChecked = $("#MyCheckBox1").attr('checked');      
    alert(isChecked);
}

Not sure if it'll help you, but that's my 20 cent. 不确定它是否会对你有所帮助,但这是我的20美分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM