The Dispatchevent (evt) method of the M53 update after the Chrome browser does not trigger a file download

Source: Internet
Author: User

A classic JS foreground file download method:

1 varALink = document.createelement (' A ');2 varDatatype= "Data:text/plain;charset=utf-8,";3Alink.href = datatype+content;4Alink.download =filename;5 varEVT = Document.createevent ("htmlevents");//Create an event6Evt.initevent ("click",false,false);//This is a click event7Alink.dispatchevent (EVT);

Google thinks: "Click Hyperlink Download File" is a "default response", and the default response should not be triggered by the script, so starting from the M53 version of the ban all scripts triggered by the default response, the download method is invalid.

Temporary solution: Add the ALink to the DOM and let the user manually click on the hyperlink to download.

The Dispatchevent (evt) method of the M53 update after the Chrome browser does not trigger a file download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.