When working in a WebView, I have the option to either load JavaScript code using
view.stringByEvaluatingJavaScriptFromString
or by directly loading it into the JS context retrieved via view.mainFrame.javaScriptContext
.
The challenge arises when I navigate to a new URL, whether within the WebView.mainFrame or through JavaScript with methods like setting window.location
. In such cases, all previously loaded JavaScript code gets cleared and needs to be reloaded. This becomes problematic especially when navigating in JS code and wanting to seamlessly continue after that. Is there any way to prevent clearing all existing JS code and specifically avoid interrupting current JS operations?