I want to be able to save any website in a WKWebView, and restore it at anytime through another button.
I tried downloading the HTML of the website:
public func getHtml(completion: @escaping (String?, URL?) -> Void) {
webView.evaluateJavaScript("document.documentElement.outerHTML.toString()") { html, error in
let html = html as? String
completion(html, self.webView.url)
}
}
and restoring the html using:
webView.loadHTMLString(html, baseURL: url)
But loading the html results in losing the formatting for the UI: https://i.stack.imgur.com/Y3S7W.png
Is there a way to save / restore the formatting of the url?