edsion996

webstorm 的 open in browser,与直接打开文件有什么区别

  •  
  •   edsion996 · Jul 23, 2018 · 2127 views
    This topic created in 2981 days ago, the information mentioned may be changed or developed.

    代码: https://gist.github.com/edsion1107/39a3edb538b7f6ddfb70d067bc455a8b

    参考了这个帖子/t/472124

    html2canvas.js文件是从这里来的.

    上面的代码,我保存为 index.html。

    情况一:如果是从 webstorm 里,右键选择 open in browser,打开后地址栏显示: http://localhost:63343/demo/index.html?_ijt=69hjpu5jphbuja1p4kmgsfdam6。这个时候点击那个 button 不会报错,而且也能“截图”。

    情况二:如果是直接在 finder 里,直接右键通过 chrome 打开,此时点击 button,提示:Uncaught (in promise) DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

    为啥?

    1 replies    2018-07-23 20:32:36 +08:00
    yimity
        1
    yimity  
       Jul 23, 2018
    一个走的是 http 服务,浏览器信任的,一个是 file,打开的本地文件,浏览器不信任。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3411 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:31 · PVG 18:31 · LAX 03:31 · JFK 06:31
    ♥ Do have faith in what you're doing.