我正在使用以下内容更改表单操作:
window.onload = function() {
document.getElementById('pdf').onclick = addExportEvent;
document.getElementById('xls').onclick = addExportEvent;
document.getElementById('xml').onclick = addExportEvent;
document.getElementById('csv').onclick = addExportEvent;
}
function addExportEvent() {
data = grid.getAllGridData();
document.getElementById('dados').setAttribute('value', encodeURIComponent(JSON.stringify(data)));
formulario = document.getElementById('formulario'); // Line 55!
formulario.action = 'php/' + this.id + '.php';
formulario.submit();
return false;
}
但它不适用于Internet Explorer。它返回以下错误:
Message: The object doesn't support the property or method.
Line: 55
Character: 2
Code: 0
URI: http://www.site.com/javascript/scripts.js
答案 0 :(得分:1)
我认为Andy E的主管的评论就是在头上发表的。你正在分配正确的元素,但没有使用var来声明它会使IE堵塞和窒息以及各种不好的东西。其他浏览器处理这个很好。所以你试图访问公式而不是声明它,这意味着它永远不会得到id的值:formulario
function addExportEvent() {
var data = grid.getAllGridData();
document.getElementById('dados').setAttribute('value', encodeURIComponent(JSON.stringify(data)));
var formulario = document.getElementById('formulario'); // Line 55!
formulario.action = 'php/' + this.id + '.php';
formulario.submit();
return false;
}