Web浏览器导航 [英] WebBrowser Navigation

查看:181
本文介绍了Web浏览器导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web浏览器控件,当任何页面的innerText具有代码重定向"文本时,该控件都导航到html页面"TopicNotFound".我已经将此检查文本和导航的内容写到了webbrowser导航事件内的TopicNotFound(TNF)html,因为那只是在完全形成webbrowser的文档对象时.
例如:

I have a webbrowser control which navigates to a html page "TopicNotFound" when the innerText of any page has "Code Redirecting" text. I have written this check for the text and the navigation thereafter to the TopicNotFound(TNF) html inside the navigated event of webbrowser, since thats only when the document object of webbrowser is fully formed.
for eg:

private void helpBrowser_Navigated(object sender, NavigationEventArgs e)
{
mshtml.HTMLDocument htmlDoc = (mshtml.HTMLDocument)this.helpBrowser.Document;
           if (htmlDoc != null &! String.IsNullOrEmpty(htmlDoc.documentElement.innerText))
           {
               if (htmlDoc.documentElement.innerText.Contains(pageInnerText))
..
....
}


但是这里的问题是,每当显示TopicNotFound html页面并单击向后导航按钮时,该按钮通常会将我带到Web浏览器中的上一个托管页面,它会不断地导航到相同的TopicNotFound html,像是agian一样,然后再次在导航"事件,当浏览器看到内部文本为代码重定向"时,我将浏览器设置为导航到TNF页面.


But the problem here is whenever the TopicNotFound html page is displayed and I click the back navigation button , which will typically take me to the previous hosted page in the webbrowser, it constantly navigates to the same TopicNotFound html, as agian and again inside the "navigated" event, I set the browser to navigate to TNF page when it sees the inner text to "Code Redirecting". Is there any solution for this problem???

推荐答案

您可以使用NavigationEventArgs.ExtraData来做到这一点.这是vb.net中可能提供一些想法的内容.

http://wpfglue.wordpress.com/tag/navigation/ [ http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.removebackentry.aspx [ ^ ]

祝你好运!
You could maybe use the NavigationEventArgs.ExtraData to do that. Here''s something in vb.net that might give some ideas.

http://wpfglue.wordpress.com/tag/navigation/[^]

Or maybe even better, you could use the RemoveBackEntry before you link to the TopicNotFound.

http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.removebackentry.aspx[^]

Good luck!


您好..我找到了解决此问题的方法.我使用了一个标志,该标志将指示何时调用来自后退或前进导航.然后,在Web浏览器的受导航事件中检查该标志,并且如果内部文本包含代码重定向",我只是要求我的浏览器一旦被agian向后导航,就解决了问题!感谢所有帖子!
Hi .. I have found a workaround for this issue. I used a flag which will indicate whenever the call is from back or forward navigation. Then I check this flag inside the navigated event of my web browser and if the inner text contains "Code redirecting", I just ask my browser to navigate backwards once agian, which solved the issue!! Thanks for all the posts!!


这篇关于Web浏览器导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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