问题
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?
回答1:
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)
来源:https://stackoverflow.com/questions/10825806/unable-to-set-form-action-via-javascript-errorobject-doesnt-support-this-prop