我正在尝试弄清楚如何在WKWebView中恢复后退列表。 Apple默认将重新阅读的后置列表。但是,Firefox,Chrome和其他移动浏览器都可以将其恢复每个会话。
这就是Firefox在iOS上恢复它的方式: https://github.com/mozilla-mobile/firefox-ios/wiki/historation-restoration-restoration-in-wkwebview-(and-error-pages)
这是JS/HTML代码用于访问DOM历史记录API:
在应用中?
似乎您需要访问指向此JS文件的 local://
url。
I am trying to figure out how to restore the back forward list in a WKWebView. Apple defaults the BackForwardList to be readonly. However, FireFox, Chrome, and other mobile browsers are able to restore it each session.
This is how FireFox restores it on iOS: https://github.com/mozilla-mobile/firefox-ios/wiki/History-Restoration-in-WKWebView-(and-Error-Pages)
Here is the JS/HTML code that's used to access the DOM History API: https://github.com/mozilla-mobile/firefox-ios/blob/041c85483b1aa4a4e357d8bd9419550e4f20347a/Client/Assets/SessionRestore.html
In order to load this file and restore a WKWebView's history, do you need to spin up a local server within the app?
It seems like you would need to in order to access a local://
url that points to this JS file.
发布评论
评论(1)
是的,这就是他们正在做的事情,根据。代码中有许多引用
internal://
,internurl
struct in urlextensions.swift.swift 。该文件中也有会话恢复的内容,例如var issessionRestore:bool
。如果还没有,请克隆该项目并将其打开在XCode中,以更轻松地导航和搜索。
Yes, that's what they are doing, according to WebServer.swift. There are many references in the code to
internal://
, and anInternalURL
struct in URLExtensions.swift. There are session restoration things in that file as well, such asvar isSessionRestore: Bool
.If you haven't already, clone the project and open it in Xcode for easier navigation and searching.