我有一个使用 v2 的转换 api 的有效 Web 转 PDF 按钮。
<form action="https://v2.convertapi.com/web/to/pdf?Secret=XXX&download=attachment" method="post" enctype="multipart/form-data">
<input type="hidden" name="Url" value="https://www.zg.ch/behoerden/baudirektion/statistikfachstelle/daten/gemeindeportraits.html" />
<input type="hidden" name="FileName" value="Portrait" />
<input type="hidden" name="ConversionDelay" value="5" />
<input type="hidden" name="ViewportWidth" value="1200" />
<input type="hidden" name="ViewportHeight" value="1887" />
<input type="hidden" name="PageSize" value="a4" />
<input type="submit" value="Portrait als PDF ausgeben"/>
</form>
根据页面上的选择,使用 jquery 更改 url。那部分也有效。
问题在于,人们通常需要提交两次甚至更多才能获得他们想要的所有 pdf 文件,并收到一条浏览器消息,警告他们即将再次提交表单。有什么办法可以避免这个消息吗?
一种方法是为每个可能的文件创建一个按钮,并根据使用 javascript/jquery 的选择隐藏显示整个按钮,但这似乎效率低下。
由于我在 CMS 中工作,因此我只能使用 html 和 javascript。
感谢您的帮助。
最佳答案
我不确定,但我曾经遇到过类似的问题。 我通过传递随机变量或时间戳以及 URL 来解决这个问题 即,
https://v2.convertapi.com/web/to/pdf?Secret=XXX&download=attachment&ignorethisparam=currenttimestamp
关于javascript - 使用 web to pdf api post 避免 "double post"浏览器消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49853863/