在javascript中发布表单

时间:2011-05-05 14:46:36

标签: javascript forms

WinHandle=window.open('',winName,features);
var form1 = WinHandle.document.createElement("form");
And I have something like this 
WinHandle.form1.setAttribute("id",id);
WinHandle.form1.setAttribute("method","post");
WinHandle.form1.setAttribute("action",target);

当我执行此代码时,我会发现以下脚本错误:

Winhandle.form1 is null. 

任何人都可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

创建表单时,您已分配对变量form1的引用。因此,要访问该引用,请继续使用声明的变量:

form1.setAttribute("id",id);
form1.setAttribute("method","post");
form1.setAttribute("action",target);