编码'时出错'至'%3F'在谷歌浏览器中

Error on encoding '?' to '%3F' in Google Chrome

本文关键字:谷歌浏览器 %3F 出错 编码      更新时间:2023-09-26

我有一个URL,比如

bulkmessaging/public/pdf/messagereport_pdf.php

现在我添加一个查询字符串,例如:

bulkmessaging/public/pdf/messagereport_pdf.php?company="+company+"&user="+user+"&reportfor="+reportfor+"

我想在重定向此路径时下载一个PDF,但当我重定向该路径时,?在Google Chrome中被编码为%3F,我没有得到PDF。该代码在Mozilla Firefox上运行良好。当使用Chrome重定向时,它应该仅在URL中保留?

location.pathname = "bulkmessaging/public/pdf/messagereport_pdf.php?company="+company+"&user="+user+"&reportfor="+reportfor+"";

这是我重定向PDF文件的Javascript中的代码。

有人能帮我吗?

与其使用location.pathname重定向到PDF,不如使用window.location:

window.location = "bulkmessaging/public/pdf/messagereport_pdf.php?company="+company+"&user="+user+"&reportfor="+reportfor+"";