开发者

javascript submit() is not a function? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

submit is not a function in javascript

Why is the following basic javascript function giving me an error document.getElementById("form").submit is not a function.

The only thing i have on a page is a form and this javascript function. I want开发者_开发百科 he form to auto submit when page is accessed.

<script>
 window.onload = function(){
 document.getElementById('form').submit();
}
</script>


Make sure that there is no name="submit" or id="submit" in the form


This is probably because the form contains input with name=submit; then the submit property contains object of the element. Rename it or use

document.createElement('form').submit.call(document.getElementById('form'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜