获取"SCRIPT438:对象不'IE 10出现错误

Getting "SCRIPT438: Object doesn't support this property or method " error on IE 10

本文关键字:IE 10出 错误 对象 quot SCRIPT438 获取      更新时间:2023-09-26

我有一个javascript方法来改变表单的动作,然后提交。

$(document).on('click','#q7', function(event) {
    event.preventDefault();
    document.forms[0].action = "questionnaireQ7AvenantsAction.do?method=rechercheQuestion&typeQ=q7&modeQ=display";
    document.forms[0].submit();
});

以上代码在除IE以外的所有浏览器中都可以正常工作。我正在使用IE 10。我在这行得到错误:

document.forms[0].action = "questionnaireQ7AvenantsAction.do?method=rechercheQuestion&typeQ=q7&modeQ=display";` 

错误是

SCRIPT438:对象不支持此属性或方法

任何帮助将不胜感激,因为我已经在这个问题上卡住了两天。

由于您已经使用jQuery作为事件处理程序,您还可以使用它来修改表单。试试这个:

$(document).on('click', '#q7', function(e) {
    e.preventDefault();
    $('form:first').attr('action', 'questionnaireQ7AvenantsAction.do?method=rechercheQuestion&typeQ=q7&modeQ=display').submit();
});