我需要找到一种方法让 api url 使用打开的实际页面将页面转换为 pdf。我的链接不起作用 - 它只是将用户带回 Web 应用程序登录页面。有什么想法吗?
<a href="#" onclick="location.href='http://www.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=' + escape(window.location.href)">Save this page as PDF</a>
另外,如果我想对网址进行编码,我该如何添加它?
谢谢
最佳答案
escape函数已弃用,您应该使用 encodeURI或encodeURIComponent .
假设您输入了有效的 API key ,我确实没有发现您发布的内容有任何问题。
如果问题仍然存在,我建议您联系 html2pdf.co.uk 支持 here .
祝你好运,希望这会有所帮助。
编辑:
在 official documentation他们建议您使用此链接:
<a href="http://www.htm2pdf.co.uk/display">Save this page as PDF</a>
你尝试过吗?
关于javascript - API 不适用于 Javascript window.location,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30367113/