Visual Basic 脚本 Web 浏览器控件
如何为 Webbrowser 控件创建一个按钮以返回页面而不重新加载页面?
重新加载就是……。像这样,或者?
Webbrowser.GoBack() ??
并且无需重新加载?有可能吗?
谢谢xu!
how can I make a button for a Webbrowser Control to go back a page without reloading the page?
With reloading it is sth. like this, or?
Webbrowser.GoBack() ??
And without reloading? Is there a posibility?
Thank xou!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,当您执行 GoBack 时,它已经尝试从计算机本地缓存中检索页面,因此它不会发送部分或完整刷新请求。
在浏览会话期间,WebBrowser 控件和 Windows Internet Explorer 维护会话期间访问的所有网站的历史列表,除非您在使用 Navigate 方法时指定 navNoHistory 标志 - 在这种情况下您将无法返回,因此请通过调用 .CanGoBack 来检查是否可以,因为这将返回 True 或 False,具体取决于是否可以。
或者,您可以使用 CommandStateChange 事件来检查向后导航的启用状态。如果事件的 CSC_NAVIGATEBACK 命令被禁用,则已到达历史列表的开头,并且不应使用 GoBack 方法。
所以基本上 GoBack 方法默认情况下不会执行刷新,但是,如果您想执行刷新,可以执行两种类型的刷新,如果您愿意,我可以告诉您这些,所以请告诉我。另外,如果您还有任何其他问题,或者我可以帮助您解决与此问题或您试图解决的问题有关的任何其他问题,请告诉我。
干杯,很快就和你说话了。
Well, when you do a GoBack, it already tries to retreive the page from your computers local cache, so it doesn't send a partial or a full refresh request.
During a browsing session, the WebBrowser control and Windows Internet Explorer maintain a history list of all Web sites visited during a session, unless you specify the navNoHistory flag when you use the Navigate method - in this case you won't be able to go back, so check to see if you can by calling .CanGoBack as that will return a True or False depending on if it can or can't.
Or, you can use the CommandStateChange event to check the enabled state of backward navigation. If the event's CSC_NAVIGATEBACK command is disabled, the beginning of the history list has been reached, and the GoBack method should not be used.
So basically the GoBack method will not do a Refresh by default, however, if you want to do a refresh, there are 2 types of refreshes you can do, I can tell you about those if you want, so just let me know. Also, let me know if you have any other questions or if there is anything else i can help you with relating to this problem or the problem you were trying to solve.
Cheers, speak to you soon.
这是很老的帖子,但这里有一个答案,假设我们有一个带有 webBrowser 控件和按钮的 WPF 表单。请注意,该按钮在 xml 定义中设置为禁用。
在表单 xaml.cs 文件中,我们需要捕获事件以根据 webBrowser 控件的状态打开/关闭“后退”按钮。我们还需要跟踪按钮的 IsEnabled 值。因此,为 xaml.cs 文件添加一个名为firstLoad 的私有布尔值。
如果用户向前导航,然后多次尝试返回,我们还需要检查并(重新)禁用该按钮。
This is very old post, but here is an answer, assuming we have a WPF form with a webBrowser control and a button. Note the button is set to disabled in the xml definition.
In the forms xaml.cs file we need to catch the events to turn the Back button on/off depending on the state of the webBrowser control. We also need to track the IsEnabled value of the button. So for the xaml.cs file add a private bool called firstLoad.
We also need to check and (re)disable the button if the user navigates forward, then trys to go back to many times.