admin管理员组文章数量:1192919
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");
}
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");
}
Share
Improve this question
edited Aug 20, 2017 at 5:59
Osama AbuSitta
4,0664 gold badges37 silver badges54 bronze badges
asked Aug 20, 2017 at 5:18
Code geekCode geek
911 silver badge5 bronze badges
2
- Can you provide an minimal reproducible example ? Do you have some ad-block plugin ? – Kaiido Commented Aug 20, 2017 at 10:04
- yes, I have an ad block plugin, but I disabled it while checking, so that doesn't seem to be the problem. – Code geek Commented Aug 21, 2017 at 13:44
2 Answers
Reset to default 16While it's no longer possible to do this in Chrome, there are workarounds, such as opening a blank document and writing to it.
var win = window.open();
win.document.write("<img src='"+canvas.toDataURL()+"'/>");
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 for security reasons.
Instead use the workaround proposed by @Savoo here in the other answer or use a download anchor and click it via JavaScript.
本文标签: javascriptwindowopen() opens a blank screen in chromeStack Overflow
版权声明:本文标题:javascript - window.open() opens a blank screen in chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738398939a2084666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论