javascript 提交 2 个表单在 chrome 中不起作用

标签 javascript forms google-chrome

我有 2 个表单要在一次提交点击时提交,以下载 2 个文件。

这是在 Firefox 中下载 2 个文件,但在 chrome 中只下载 1 个文件。

我已根据要求编辑并插入了完整代码。

完整代码:

                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>EXPORT INVOICE </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <SCRIPT LANGUAGE="JavaScript">
      function runscript()
      {
        document.f1.submit();
        document.f2.submit();
      }
    </script>
    </head>

    <body>

    <form name="f1" method="post" action="export-tst-with-header.php" target="_blank">

    <table width="810" height="140" border="0" cellpadding="5" cellspacing="0" class="uniq" align="center">
      <tr class="uniq">
        <td width="363" valign="middle">
        <br>
        <span class="sty2">Enter to export From Invoice No.:</span>     <input type="text" size='10' maxlength='10' name="finv" onblur="showfrom(this.value);">
        &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <span class="sty2">To Invoice No:</span>&nbsp; <input type="text"  size='10' maxlength='10' name="tinv" onblur="showto(this.value);">
        </td>
      </tr>
      <tr class="uniq">
        <td width="363" valign="top"><div align="center"><br>
            <br>
            </form>

            <form name="f2" method="post" action="export-tst-with-header2.php" target="_blank">
            </form>

            <input type="button" value="Export" onClick="runscript();" />



    &nbsp;&nbsp;
    &nbsp;&nbsp;
          <a href='index.htm' target='_parent'><input name="close" type="button" value="Close !"></a>
        </div></td>
      </tr>
    </table>

    <br>
    </body>
    </html>

最佳答案

编辑:这是我运行的测试,我在其中清理了 HTML 和 JS 中的许多问题。我发现这个解决方案实际上会同时访问 Chrome 中的两个 URL。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>EXPORT INVOICE </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
    function runscript() {
        document.forms.f1.submit();
        window.setTimeout(function() {
            document.forms.f2.submit();
        }, 500);
    }
</script>
</head>
<body>
    <table width="810" height="140" border="0" cellpadding="5" cellspacing="0" class="uniq" align="center">
        <tr class="uniq">
            <td width="363" valign="middle">
                <form name="f1" method="post" action="export-tst-with-header.php" target="_blank">
                    <br />
                    <span class="sty2">Enter to export From Invoice No.:</span>
                    <input type="text" size='10' maxlength='10' name="finv" onblur="showfrom(this.value);" />
                    &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="sty2">To Invoice No:</span>&nbsp; 
                    <input type="text"  size='10' maxlength='10' name="tinv" onblur="showto(this.value);" />
                </form>
            </td>
        </tr>
        <tr class="uniq">
            <td width="363" valign="top">
                <div align="center">
                <br />
                <br />
                <form name="f2" method="post" action="export-tst-with-header2.php" target="_blank">
                </form>
                <input type="button" value="Export" onClick="runscript();" />
                &nbsp;&nbsp;
                &nbsp;&nbsp;
                <a href='index.htm' target='_parent'><input name="close" type="button" value="Close !"></a>
                </div>
            </td>
        </tr>
    </table>
    <br />
</body>
</html>

关于javascript 提交 2 个表单在 chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16356663/

相关文章:

google-chrome - ctrl+g 和 ctrl+f 的区别

javascript - Html5 输入 slider 未更新

javascript - Firestore规则-查询文档是否存在-权限不足

javascript - 匿名函数并不总是有返回值

javascript - JS : convert 2D object with keys to transposed csv

php - 根据下拉选择自动填充文本字段,其中所有值都来自 MYSQL 表

javascript - 在 Python 中解析 BeautifulSoup 后的脚本标签

javascript - 为什么我在使用 javascript 提交表单而不是加载页面时无法获取发布数据?

javascript - 如何根据表单选择更改图像?

google-chrome - 提高 Chrome 扩展程序版本是否足以强制升级?