How to clear back forward list in UIWebview on iPhone?

前端 未结 8 478
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 13:09

I want to access/clear the back forward list as if the UIWebView is new again. Is there any public API or workaround to do this?

I\'ve tried:

         


        
8条回答
  •  旧时难觅i
    2020-12-10 14:08

    I've tried almost every solution posted without much success. My case is for Childbrowser phonegap plugin, but is based in the same problem, a single webview instance used to show external pages in my application. When I show an external page, the webview maintains the history of previous pages shown. I wanted to remove the history when I show a new external webpage.

    After some research, I've found a solution in this SO post that worked for me.

    [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"];
    

    In the case of childbrowser, I placed it in the method -(IBAction) onDoneButtonPress:(id)sender, which previously inserted a blank page to start blank (but with back button enabled).

    HTH! Milton.

提交回复
热议问题