Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load local file in Chrome App Webview

In Chrome packaged apps you can use to load external pages inside the app. Is there a way to make them load a local file (an html file inside the packaged app)? I can't use iframe, because iframe wont support external resources (scripts, images, whatever).

like image 622
Fabis Avatar asked Apr 29 '14 20:04

Fabis


2 Answers

Don't have any code to show, but try this: Assuming you can read the local file (must use chrome.fileSystem.chooseEntry or have a retained entry on the file or its containing directory) and get a FileEntry object, you can then create a FileReader to get the file as a data URL. Then you can use that data URL directly in a webview. (Must have webview permission, in addition to the permissions needed to access the FileEntry.)

[Above is from memory while I'm eating breakfast. Might have some API names slightly off, but I hope you get the general idea.]

like image 101
Marc Rochkind Avatar answered Sep 21 '22 19:09

Marc Rochkind


The local-resources sample has an example of loading an html file in a webview. You need to specify the files in the webview.partitions section of manifest.json.

like image 27
Sarah Elan Avatar answered Sep 21 '22 19:09

Sarah Elan