Window.location.href open address of each terminal performance is different, expected to pop up the download box, what should be done?

for example, use window.location.href to open this address: "http://srv-file.lehuomao.com/R.FhLetITQrMkKPH7J6-gz_qu3Rdbx.8IqVjCe?attname=114935985_0-1524097469-31b1c44e-63ff-ecea_00001.ts&e=1544177078&token=A-SxvcKX-cElDR8djvNfz0BbAx0-tsc5iD9gf7qq:_BFUpEJ7G_9k0NhZjxM-XSOukg4="

"

Android can pop up the download box normally;
safari opens this page:
clipboard.png

Open the garbled code directly in Wechat
what to do with it

Jan.19,2022

the content-type returned by your address is video/MP2T
different browsers may have different treatments for this.
if you want to download, you need to change the content-type, for example, to application/octet-stream (binary stream).


window.location.href is the punch-in address of the pop-up new browser window. The pop-up download box is the behavior of the browser itself, and you cannot intervene through the script.

the table is installed because the browser does not recognize the file type, so it is prompted to download by default. It has nothing to do with whether you use window.location.href or not.

ios does not support downloading any files other than pictures, so you have no solution in safari.

the normal practice in Wechat is to guide the user to open it through the browser in the upper right corner.

Menu