如何在加载页面之前清除WebView的内容? [英] How do I clear a WebView's content before loading a page?

查看:3478
本文介绍了如何在加载页面之前清除WebView的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Cocoa应用程序中嵌入了一个WebView,其中我加载了一个外部网页。每次用户点击一个按钮,视图打开并显示页面。



问题是,第二次用户打开WebView,前一页仍然可见。



如何在加载新页面之前清除WebView?



我能找到的最接近的解决方案是:

  [webView stringByEvaluatingJavaScriptFromString:@document.open(); document.close()];有没有更好的方法?


谢谢!

解决方案

尝试此操作...加载about:blank


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 visible. 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"

这篇关于如何在加载页面之前清除WebView的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆