2014年10月26日 星期日

在Chrome extensions中使用gif.js

最近看開chrome extension時遇到了gif.js使用上的問題,原因是在gif.js裡會使用到web worker,可是在chrome extension 中會出現SecurityError,搜尋google在stackoverflow中的一篇問答找到了原因,原來是因為chrome自身的bug所以讓extension無法讀取web worker。

步驟

1. 在chrome extension中加入patch-worker.js
2. 將gif.js檔案中的['gif.worker.js']取代成[chrome.runtime.getURL('path/gif.worker.js')]。
(註:path為你放gif.js的路徑)

沒有留言:

張貼留言