Anchor tag download attribute downloads file twice






















One is for an Excel file and one for PDF. The Excel file downloads. The PDF opens in new tab instead. Why is this happening? Code below:. So essentially what is happening is that when you link to a file URL, the browser opens that URL and if it has accessibility to display the content, it almost always will.

Some most common examples of this are image files. However, if the browser can't read the file type. PDFs are readable and accessible by most modern browsers so by default, the browser is set to open the file instead of download it. Because of this accessibility, most modern browsers have introduced settings that allow users to decide on a machine by machine basis whether or not a PDF or any other readable file should open in another window or download by default.

In many cases, even with the download attribute, the browser can still decide for itself how to handle the file. Report Error. Your message has been sent to W3Schools. W3Schools is optimized for learning and training. Firefox versions before 82 prioritize the header and will display the content inline.

Content categories Flow content , phrasing content , interactive content , palpable content. Permitted content Transparent , except that no descendant may be interactive content or an a element, and no descendant may have a specified tabindex attribute. Tag omission None, both the starting and ending tag are mandatory. Size Interactive elements, like links, should provide an area large enough that it is easy to activate them.

Understanding Success Criterion 2. Hand tremors and the giant-button-problem. Flow content , phrasing content , interactive content , palpable content.

Transparent , except that no descendant may be interactive content or an a element, and no descendant may have a specified tabindex attribute. When href attribute is present: button checkbox menuitem menuitemcheckbox menuitemradio option radio switch tab treeitem When href attribute is not present: any.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 7 years, 9 months ago.

Active 1 month ago. Viewed 91k times. Why is this not working: download. Improve this question. Typically the chromium team releases an update every 2 weeks so you can expect a fix soon since this is marked as Pri-1 which I assume means highest priority. Here is a bit that worked for me in Chrome and Firefox. I'm building a xls file out of a table. When I tried this code, I was not able to get results in IE plus this code only iterates over td , it will skip any th present in your table.

I have modified the code to resolve both the issues I was facing:. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Anchor tag download attribute not working :Bug in Chrome Asked 7 years, 6 months ago.



0コメント

  • 1000 / 1000