-2

您好我正在使用pdftron webviewer.js.創建色度應用程序。我能夠在瀏覽器上渲染pdf。但是當我在我的Chrome應用程序中包含pdftron webviewer庫時,I我得到一些錯誤。這是網絡版pdftron webviewer控件。document.write()和localStorage在chromeApp中不可用

PDFTronWebViewer Sample

我收到此錯誤: 1)document.write()的和localStorage的是不是打包應用程序可用。拋出新的錯誤(消息);

回答

-1

而不是重寫index.js文件中的window.localStorage,您可以更改lib/HTML5/ControlUtils.js以更改_storePreference和_getPreference函數的工作方式。而不是讓它們使用localStorage的(這是不提供的Chrome應用),你可以使用谷歌的存儲API https://developer.chrome.com/extensions/storage

_storePreference: function(key, value) { 
    chrome.storage.local.set({key: JSON.stringify(value)}); 
} 

如果你願意,你可以覆蓋這些功能在您的config.js文件即

window.ControlUtils.userPreferences._storePreference = function(key, value) { 
    chrome.storage.local.set({key: JSON.stringify(value)}); 
} 
+0

這是行不通的,因爲'chrome.storage.local'不是一個下拉更換localStorage'的'。它是異步的,而'localStorage'是同步的。 – Xan

+0

根據OP,還有一個'document.write()'問題。 – Xan

+0

謝謝Xan&Ryan,我爲此創建了一個示例,我得到兩個像localStorage和document.write()這樣的錯誤。我們可以解決這個問題嗎?這是我的示例: - https://jumpshare.com/v/LVWrorMVVkJJB7XvcidN –

0

相反的document.write你應該使用document.createElement

相關問題