Reputation: 95
I'd like to create a HTML app that stores another web page (HTML+CSS+JS in one file) in IndexedDB and can open it in the browser.
I know that I can do it using File system API: create temporary file, write page content from DB to this file and change browser location to this file. But I read that Filesystem API is supported only by Chrome so I'm wondering if there is another approach, supported by standards?
Upvotes: 2
Views: 1689
Reputation: 27460
If you have your document as a string then you can use data URL scheme to load it in window:
window.open('data:text/html;charset=utf-8,' +
encodeURIComponent( // Escape for URL formatting
'<!DOCTYPE html>'+
'<html lang="en">'+
'<head><title>Embedded Window</title></head>'+
'<body><h1>42</h1></body>'+
'</html>'
)
);
Upvotes: 1