Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript在嵌入在div中的html页面中提交表单_Javascript_Html_Forms_Dom - Fatal编程技术网

Javascript在嵌入在div中的html页面中提交表单

Javascript在嵌入在div中的html页面中提交表单,javascript,html,forms,dom,Javascript,Html,Forms,Dom,我有一个主页(index.html),其中包含一个嵌入的html页面(sample1.html),我从document.getElementById(“divid”).innerHTML加载该页面 在这个sample1.html中,我有一个表单: 我不知道如何使用index.html级别中包含的javascript提交此表单 我尝试了以下3个选项: document.forms[0].submit(); 文件。表格1。提交(); document.form[“sampleform1”]。sub

我有一个主页(index.html),其中包含一个嵌入的html页面(sample1.html),我从
document.getElementById(“divid”).innerHTML加载该页面

在这个sample1.html中,我有一个表单:

我不知道如何使用index.html级别中包含的javascript提交此表单

我尝试了以下3个选项:
document.forms[0].submit();
文件。表格1。提交();
document.form[“sampleform1”]。submit()

他们都失败了。我的问题是-如何在嵌入到元素中的html页面中获取的句柄?不确定这在DOM中是怎样的结构

谢谢。

试试这个


document.getElementById(“sampleform1”)。单击()

HTML页面是否嵌入到元素中?你是说iframe?不是iframe。我这样加载它:document.getElementById(“divid”).innerHTML='';document.getElementById为name/id值返回null。我认为从index.html中,嵌入的html中的元素无法被识别。