在用javascript截取提交后,无法“提交()`html表单

问题描述:

我正在尝试拦截提交表单以更改关键字标签的值。

I'm trying to intercept the submission of a form in order to change the value of my keywords label.

我有以下代码:

<HTML>
<FORM name="searchForm" method="get" action="tmp.html" >
<input type="text" name="keywords" />
<input type="button" name="submit" value="submit" onclick="formIntercept();"/>
</FORM>
<SCRIPT language="JavaScript">
document.searchForm.keywords.focus();
function formIntercept( ) {
    var f = document.forms['searchForm'];
    f.keywords.value = 'boo';
    f.submit();
};
</SCRIPT>
</HTML>

当我在chrome中运行此选项并单击提交按钮时,关键字标签将更改为 boo ,但javascript控制台说:

When I run this in chrome and click the submit button the keywords label changes to boo, but the javascript console says:

 Uncaught TypeError: Property 'submit' of object <#an HtmlFormElement> is not a function.

如何使用操纵的关键字提交表单?

How can I submit the form with the manipulated keywords?

<html>
<head></head>
<body>
<form name="searchForm" method="get" action="tmp.html" onsubmit="formIntercept(this);">
<input type="text" name="keywords" />
<input type="submit" name="submit" value="submit"/>
</form>
<script type="text/javascript">
document.searchForm.keywords.focus();
function formIntercept( form ) {
    form.keywords.value = 'boo';
    //form.submit();
}
</script>
</body>
</html>