[英]c# webbrowser control, navigates on dynamic menu hover?
I have a form in my winforms app that acts as a built-in browser. 我的winforms应用程序中有一个表单,它充当内置浏览器。 It uses the .net webbrowser control.
它使用.net Webbrowser控件。 Pretty simple.
很简单 I have a textbox as an address bar, and buttons for control.
我有一个文本框作为地址栏,还有用于控制的按钮。 When I navigate to my website, my website uses a .net menu control to present a hover menu.
当我导航到我的网站时,我的网站使用.net菜单控件来显示悬停菜单。 When I hover over the menu (using my browser form), the address bar changes to: http://domainname/WebResource.axd?etc/etc/etc , unexpectedly
当我将鼠标悬停在菜单上时(使用浏览器表单),地址栏意外更改为: http://domainname/WebResource.axd?etc / etc / etc
I am trapping the webbrowser_navigating event and setting the Text property of the address bar to e.Url.ToString() 我正在捕获webbrowser_navigating事件并将地址栏的Text属性设置为e.Url.ToString()
Of course, this is not the expected result, and IE doesn't do this. 当然,这不是预期的结果,并且IE不会这样做。 What am I missing?
我想念什么?
UPDATE: 更新:
Here's the only way I could come up with how to do this: 这是我想出办法的唯一方法:
string url = e.Url.ToString().ToLower(); // Only change the address bar under certain circumstances // Filter out some navigating changes if ((StringUtil.Empty(e.TargetFrameName) || e.TargetFrameName.ToLower() == "_blank") && !url.Contains("webresource.axd") && !url.Contains("javascript:") && !url.Contains("about:blank")) { toolStripAddress.Text = e.Url.ToString(); }
请参阅上方的Sanjay评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.