Javascript 不适用于 Chrome 和 IE,但适用于 Firefox

标签 javascript

这是在 Mozilla 中完美运行但在 IE 和 chrome 中运行不完美的 javacript 代码。

function updateTable(tableID) 
{ 
    alert('inside the update'); 
    var arrayTemp=new Array();
    var str='';
    var arraycount=0;
    try {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;

        for(var i=0; i<rowCount; i++) {
            var row = table.rows[i];
            var chkbox = row.cells[4].childNodes[0];                
            if(null != chkbox && true == chkbox.checked) {

           str+=  document.getElementById("flag"+i).value;
           str+=',';
           str+=  document.getElementById("Selected"+i).value;
           str+='`';




            } 

        }
        document.forms[0].updatearray.value=str;
        alert(' value is '+document.forms[0].updatearray.value);
        document.forms[0].submit();

        alert('Checkingdddddd');
    }catch(e) {
        alert(e);
    }
}

这里的表单在 IE 和 Chrome 中没有提交。请告知是否有任何补救措施。

我已经测试并发现 document.forms("formname").submit() 仅适用于 chrome 和 IE,但如果我使用 document.forms["formname"].submit 它不适用于 chrome 和 IE很奇怪,需要一位伟大的 JavaScript 魔术师的好建议

最佳答案

我找到了使用 document.forms[0].submit 的补救措施,因为它支持 Mozilla、IE 和 Google chrome。

答案是:

          Replace:

          document.forms[0].submit();

          To:

          document.forms[0].submit;

关于Javascript 不适用于 Chrome 和 IE,但适用于 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10892110/

相关文章:

javascript - 嵌套 JSON : How to add (push) new items to an object?

javascript - 使用一个主复选框取消/选中全部、重置所有复选框,就像 GMAIL 中一样

javascript 放在 head 前面?

javascript - 如何使用 polymer 将 HTML 注入(inject)模板

javascript - 在数组中添加字符串 - Javascript

javascript - 通过 jQuery 访问 HTML 表单

javascript - 如何在 Visual Studio 2015 中进行捆绑和缩小

javascript - TIME(日期对象)未在nodejs中更新

javascript - 为什么 v8::JSON::Parse 从 v8 比 NodeJS JSON::parse 慢得多?

javascript - 向下滚动页面时粘性表格标题单元格?