Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

javascript problem

  • 7 个回答
  • 1 人有此问题
  • 14 次查看
  • 最后回复者为 Bill

more options

Starting in January I have a problem downloading a .pdf file from my Credit Union. If I click on the download icon and inspect the element I find the following:

<a href="javascript:document.EStmt._Action.value='Save';javascript:document.EStmt._Selection.value='20180228_43';javascript:document.EStmt._StmtDesc.value='Regular Statement';javascript:document.EStmt._StmtDate.value='2/28/2018';document.EStmt.submit();"> </a>

The statement is downloaded without any extension so the PC does not know what to do with it. The strange thing it is the .pdf file without the .pdf extension. If I manually add the .pdf extension then the file works correctly.

The credit union provides a view icon. If I click on the view icon and inspect the element I find the following:

<a href="javascript:createEStmtWindow('../../CuEStatementsWE/EStatements/ViewOnNewPageWait.asp?DocID=20180228_43', '20180228_43');"> </a>

The window is opened displaying the statement. I can save the statement and it is saved correctly with the proper extension.

If I use a different browser the download works correctly. I am providing an image of what Edge presents when I click on the download icon.

This use to work. Does the credit union have a problem or does Firefox?

Why does it work correctly with Microsoft Edge, Internet Explorer, and Google Chrome?

Starting in January I have a problem downloading a .pdf file from my Credit Union. If I click on the download icon and inspect the element I find the following: <a href="javascript:document.EStmt._Action.value='Save';javascript:document.EStmt._Selection.value='20180228_43';javascript:document.EStmt._StmtDesc.value='Regular Statement';javascript:document.EStmt._StmtDate.value='2/28/2018';document.EStmt.submit();"><i class="icon-download-alt"></i>&nbsp;</a> The statement is downloaded without any extension so the PC does not know what to do with it. The strange thing it is the .pdf file without the .pdf extension. If I manually add the .pdf extension then the file works correctly. The credit union provides a view icon. If I click on the view icon and inspect the element I find the following: <a href="javascript:createEStmtWindow('../../CuEStatementsWE/EStatements/ViewOnNewPageWait.asp?DocID=20180228_43', '20180228_43');"><i class="icon view"></i>&nbsp;</a> The window is opened displaying the statement. I can save the statement and it is saved correctly with the proper extension. If I use a different browser the download works correctly. I am providing an image of what Edge presents when I click on the download icon. This use to work. Does the credit union have a problem or does Firefox? Why does it work correctly with Microsoft Edge, Internet Explorer, and Google Chrome?
已附加屏幕截图

所有回复 (7)

more options

I forgot to mention. With the download icon the name of the file is "CU".

With view icon the name of the file is "Statement.pdf".

With the other browsers the name of the file, using the download icon, is "02-28-2018.pdf" not "CU" with no extension.

more options

When a server sends a download, it can override the raw web address of the download with a friendlier file name. However, there are not supposed to be any spaces in a file name, so Firefox stops reading at the first space -- which is just after CU. To resolve that, the developers are supposed to either put the file name in quotation marks or fill the spaces with a character, such as an underscore (_) to avoid this problem. I suspect the Credit Union does not test in Firefox. Please escalate this issue to them!

more options

Can you point me to where you see the space after "CU". I do not see it.

more options

Hi Bill, you can see the spaces in your screenshot:

This is not part of the script in the page, it is sent by the server as part of the HTTP Headers preceding the PDF file. That's where the problem is.

more options

So what you are telling me is that the name of the file as displayed in Microsoft Edge should not be "CU Regular Statement 2-28-20108.pdf" it should be "CU_Regular_Statement_2-28-2018.pdf". I looked and the name of the file when I use the view option is because the name is "statement.pdf".

Am I correct?

more options

Bill said

So what you are telling me is that the name of the file as displayed in Microsoft Edge should not be "CU Regular Statement 2-28-20108.pdf" it should be "CU_Regular_Statement_2-28-2018.pdf".

No, that is not what I'm saying. The server is sending something like this:

Content-Disposition: attachment; filename=CU Regular Statement 2-28-20108.pdf;

Microsoft browsers disregard the rule that spaces in a header field terminate the value for that field; they read all the way to the end of the line. Therefore, they show the file name intended by the server.

Firefox stops at the first space and you get a file named CU or CU.pdf. Mozilla might be the last holdout following the standard (RFC 2616), which was originally related to supporting non-ANSI character sets but now might just be stubbornness (the fact that the standard often is disregarded has been noted in RFC 6266 Appendix A while quotation marks are still indicated when spaces are included RFC 6266 Examples). So we are where we are.

The solution is for the site to quote the file name when it constructs the header:

Content-Disposition: attachment; filename="CU Regular Statement 2-28-20108.pdf";

Hopefully they can make that minor change so everyone is happy.

more options

I think we are saying the same thing. I probably should not have put quotes around the name, since that would follow the rule. I put quotes around the name to highlight what I think the credit union is sending.