处理chrome中本地运行html5 canvas app的security error 18错误

在chrome中运行本地应用app的时候,如果要用到canvas之类的对象加载本地图像,如:

 function show() {
  var img = new Image();
  img.οnlοad=function(){
   var canvas=document.getElementById("canvas");
   var context=canvas.getContext("2d");
   context.drawImage(this,0,0);      
   document.getElementById("dataurl").value=canvas.toDataURL().substring( 22 );
  };
  img.src="C:\\Users\\t00200435\\Desktop\\签名.png";

  }

默认情况下会出现 SECURITY ERROR 18错误,这时运行chrome的时候需要加参数"......\chrome.exe" --allow-file-access-from-files

问题解决

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章