I have a website that uses javascript that uses angular to control what you see on the website. So http://somewebsite.com/#page1 is shown and when you click on a tab that location changes to http://somewebsite.com/#page2. There will be no actual reload on the website and therefor func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)
will not get triggered. How can you catch these hash changes?
Clearly Apple can, since the Safari webbrowser is able to show these changes in the location bar.
Update 19.33:
I did some research. Using window.onhashchange
in the Safari browser this will get fired however in the WKWebView it does not. Diving deeper I use the following javascript to return the document location href every second.
window.setInterval(function(){ alert(document.location) }, 1000);
When reading that alert in WKWebView it never shows that the location changes, while in Safari you see http://somewebsite.com/#page1 and http://somewebsite.com/#page2. It seems like WKWebView does not support this feature which is extremely annoying.