download download canvas a property tag

save.onclick = function() {
  var url = canvas.toDataURL("image/png");
  var a = document.createElement("a");
  document.body.appendChild(a);
  a.href = url;
  a.download = "我的画儿";
  a.target = "_blank";
  a.click();
};

There is a download button save in canvas panel, click on it you can download and save to a local canvas.

a property tag

  • download
    this attribute instructs the browser to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. Value as a filling file name of the property.
  • href
    the URL of limited to those based Web (HTTP) document, you can use any browser that supports the protocol. For example, it works properly in most browsers file:, ftp: and mailto: There tel :.
  • target
    • _self: The default value, in the current page loads.
    • _blank: a new window opens.

Usually click on a link usually the default is to open this page in a browser, which is not what we want. I think there is any good way to load additional tab pages of it?

  1. Press and hold the ctrlbutton click on the link will open in a new tab
  2. Middle mouse button or scroll wheel click on the link will open in a new tab
  3. Press and hold the shiftbutton click on the link will open in a new window

Reproduced in: https: //www.jianshu.com/p/7f6756fd3ddd

Guess you like

Origin blog.csdn.net/weixin_33922670/article/details/91121046