window.open() opens a blank screen in chrome

2019-05-11 12:54发布

I checked this same code in Firefox and it works perfectly. In fact, this worked in Chrome a few weeks back, but now I'm just getting a blank screen.

The code is below:

The function triggers on button click.

function saving() {
  var saveURL = canvas.toDataURL(); 
  window.open(saveURL, "_blank", "location=0, menubar=0");
}

2条回答
Summer. ? 凉城
2楼-- · 2019-05-11 13:18
          var win=window.open();
          win.document.write("<img src='"+canvas.toDataURL()+"'/>");
查看更多
三岁会撩人
3楼-- · 2019-05-11 13:24

That's because of a recent change in Chrome:

https://developers.google.com/web/updates/2017/03/chrome-58-deprecations#remove_content-initiated_top_frame_navigations_to_data_urls

You cannot open data urls directly anymore this way.

查看更多
登录 后发表回答