Javascript同源策略對context.getImageData的影響

在本機測試HTML5 Canvas程序的時候,若是用context.drawImage()後再用context.getImageData()獲取圖片像素數據的時候會拋出錯:SECURITY_ERR: DOM Exception 18。這是Javascript同源策略(Same origin policy)形成的。目前發現這個問題在Firefox和Chrome中均存在。html

解決辦法以下:
Firefox:在地址欄輸入about:config,而後設置security.fileuri.strict_origin_policy爲false
Chrome:cmd進入命令行,在命令行中運行/path-to-chrome/chrome.exe -allow-file-access-from-fileschrome

例如個人機器是:D:/program files/ChromePortable/chrome.exe -allow-file-access-from-fileside

 

 

 

 

本文轉自http://www.riaidea.com/blog/archives/358.html測試

相關文章
相關標籤/搜索