You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **MouseEvent** interface represents events that occur due to the user interacting with a pointing device (such as a mouse). Common events using this interface include click, dblclick, mouseup, mousedown.
MouseEvent derives from UIEvent, which in turn derives from Event. Though the MouseEvent.initMouseEvent() method is kept for backward compatibility, creating of a MouseEvent object should be done using the MouseEvent() constructor.
Several more specific events are based on MouseEvent, including WheelEvent and DragEvent.
将数据转换为 blob,然后创建 url 链接,赋值给 a tag 利用 a tag 实现下载文件。
functiondownloadBlob(blob,name='file.txt'){// Convert your blob into a Blob URL (a special url that points to an object in the browser's memory)constblobUrl=URL.createObjectURL(blob);// Create a link elementconstlink=document.createElement("a");// Set link's href to point to the Blob URLlink.href=blobUrl;link.download=name;// Append link to the bodydocument.body.appendChild(link);// Dispatch click event on the link// This is necessary as link.click() does not work on the latest firefoxlink.dispatchEvent(newMouseEvent('click',{bubbles: true,cancelable: true,view: window}));// Remove link from bodydocument.body.removeChild(link);window.URL.revokeObjectURL(blobUrl)}// UsageletmdBlob=newBlob(['markdown'])downloadBlob(mdBlob,'markdown.md');
The text was updated successfully, but these errors were encountered:
Download Any File from Blob
https://developer.mozilla.org/zh-CN/docs/Web/API/Blob
https://developer.mozilla.org/zh-CN/docs/Web/API/URL
https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/dispatchEvent
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
将数据转换为 blob,然后创建 url 链接,赋值给 a tag 利用 a tag 实现下载文件。
The text was updated successfully, but these errors were encountered: