无法通过javascript设置表单动作(错误:对象不支持此属性或方法) [英] Unable to set form action via javascript (error:object doesn't support this property or method)
问题描述
这是代码。 病人
是表单名称。
function settarget(page){
document.getElementById('patient')。action = page;
}
IE的确切错误信息是:
SCRIPT438:对象不支持此属性或方法
我也试过引用 document.forms [0] .action
- 同样的错误。
对于任何其他标记,名称患者
不存在重复。
这适用于Chrome和Firefox,但不是XP上的IE8或Win7上的IE9。在IE浏览器中是否存在阻止此操作的安全设置?解析方法
DOM元素(由getElementById返回)没有属性 action
。您需要在元素上设置属性。
document.getElementById('patient')。setAttribute('action',page)
Here is the code. patient
is the form name.
function settarget(page) {
document.getElementById('patient').action = page;
}
The exact error message from IE is:
SCRIPT438: Object doesn't support this property or method
I have also tried it referencing document.forms[0].action
- same error.
There is no duplication of the name patient
for any other tag.
This works with Chrome and Firefox, but not IE8 on XP or IE9 on Win7. Is there a security setting in IE that is blocking this action?
DOM elements (returned by getElementById) do not have a property action
. You need to set an attribute on the element.
document.getElementById('patient').setAttribute('action',page)
这篇关于无法通过javascript设置表单动作(错误:对象不支持此属性或方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!