开发者

How do I clear a WebView's content before loading a page?

I have an embedded WebView in my Cocoa application in which I load an external web page. Each time the user clicks on a button, the view opens and shows the page.

The problem is that the second time the user opens the WebView, the previous page is still vi开发者_Python百科sible. Instead I'd like to show a blank/empty page (together with a progress indicator).

How can I clear a WebView before loading a new page?

The closest solution I could find was to call this:

[webView stringByEvaluatingJavaScriptFromString:@"document.open();document.close()"];

Is there a better way to do this?

Thanks!


Try this... Load "about:blank"


[self.webView loadHTMLString:nil
                     baseURL:nil];

Worked for me nice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜