Javascript不会打开包含表格和表单的弹出窗口
Javascript does not open popup window with table and form in it
只要表单包含任何元素,窗口就不会打开。但是,如果表单是空的(如果您从代码中删除),则弹出窗口工作正常。
Javascript:
function openScheduleWindow() {
var scheduleWindow = window.open("", "Schedule Window", "width=700, height=200");
scheduleWindow.document.write("<html><body><table border=1> '
<tr><th>C1</th><th>C2</th></tr><tr><td>1</td><td>A</td></tr> '
<tr><td>2</td><td>B</td></tr> '
</table><form><input type="text" name="firstname"></form>");
}
您忘记转义HTML字符串中的"
。
scheduleWindow.document.write("<html><body><table border=1> '
<tr><th>C1</th><th>C2</th></tr><tr><td>1</td><td>A</td></tr> '
<tr><td>2</td><td>B</td></tr> '
</table><form><input type='"text'" name='"firstname'"></form>");
<input type="text" name="firstname">
行上的双引号导致了问题,请尝试用单引号替换它们,应该可以正常工作
function openScheduleWindow() {
var scheduleWindow = window.open("", "Schedule Window", "width=700, height=200");
scheduleWindow.document.write("<html><body><table border=1> <tr><th>C1</th><th>C2</th></tr><tr><td>1</td><td>A</td></tr> <tr><td>2</td><td>B</td></tr> </table><form><input type='text' name='firstname'></form>");
}
相关文章:
- Javascript更新孙窗口中的表单元素
- javascript弹出窗口没有正确加载html表单
- 窗口提醒或类似内容中的电子邮件表单
- 在jQuery中的IFrame中提交表单后刷新父窗口
- 仅当表单有效时关闭弹出窗口
- 使用Javascript在弹出窗口中提交表单
- 表单按钮在同一窗口中打开新的URL
- 将Overlay添加到弹出窗口并添加输入类型字段以退出表单
- 选项卡在新窗口上提交表单,原因
- 提交表单的可能性(左-/中-/在新选项卡或窗口中打开-)单击html链接
- Javascript在新窗口中重新提交具有特定维度的表单
- 提交表单时在弹出窗口中打开响应
- 提交表单后,模式窗口未关闭
- 为什么这个JS确认窗口没有在表单提交时启动
- 弹出窗口中的表单验证
- 如何在新窗口中提交表单,然后重定向父页面
- 提交在弹出窗口中创建的表单
- Php,如何打开一个小消息/表单窗口(不是新的浏览器窗口)
- 如何在javascript中关闭隐藏弹出表单窗口
- JQuery /脏表单/窗口.Onbeforeunload仅在链接选择后触发