Display child url with parent url in WKWebView background in iOS

I want to display a new instance of WKWebView , so the page currently being displayed to the user is childURL , but the other URL, parentURL , is in the reverse order of the WKWebview history, so if the user goes back in history (through a gesture or through a button that calls function WKWebView goBack ), then parentURL will be displayed.

Imagine first loading parentURL into the webview , and then click the link that goes to childURL . I want this ( childURL displayed, parentURL in the background) to be my initial state in WKWebView .

How can i do this?

+5
source share
1 answer

I suggest:

  • A WKWebView displays your childURL at the beginning.
  • When you click the return button, WKWebView enter a new parentURL request. The button must be a native iOS UIButton. After clicking the return button, change its action so that WKWebView does not request parentURL again.
  • If the back button is in .html, try interacting with javascript.
  • If you still have other problems, talk to me.

If your urls are different .html s, I think it’s easy to do what I say. Your go back will simply go to the new URL.

+2
source

Source: https://habr.com/ru/post/1259957/


All Articles