窗口打开不起作用/未被调用

window.open not working/not gets called

本文关键字:调用 不起作用 窗口      更新时间:2023-09-26

我的表单中有一个按钮,可以生成PDF文件并保存在本地机器中; 现在通过单击按钮将它们保存在本地机器中后,我也想在浏览器中查看文件以供下载(其中多个文件(;

我尝试的代码如下:

<form name="frm1" id="frm1" method="post" enctype="multipart/form-data">
         .
         .
         .
  <button type="submit" name="btnCreatePDF_8" class="btn btn-primary" onclick= "newDoc();"> Export to PDF </button>
</form>

<script>
       function newDoc()
       {
           window.open("http://localhost/MyProject/1234_1_8.pdf")
       }
</script>

它创建了PDF,但我无法让我的javascript函数(newDoc(((工作!

感谢您的帮助!另外,如果您需要更多澄清,请让我知道我必须提供更多澄清的部分。

谢谢

不要使用提交按钮。那是你的问题,它正在提交表单并调用函数。看起来表单提交正在赢得比赛。将其更改为常规按钮。

  <button name="btnCreatePDF_8" class="btn btn-primary" onclick= "newDoc();"> Export to PDF </button> // remove the type="submit"