C# webbrowser 控件,在动态菜单悬停上导航?
我的 winforms 应用程序中有一个表单,充当内置浏览器。它使用 .net webbrowser 控件。很简单。我有一个文本框作为地址栏,以及用于控制的按钮。当我导航到我的网站时,我的网站使用 .net 菜单控件来显示悬停菜单。当我将鼠标悬停在菜单上(使用浏览器表单)时,地址栏更改为: http:// /domainname/WebResource.axd?etc/etc/etc,没想到
我捕获了webbrowser_navigating事件并将地址栏的Text属性设置为e.Url.ToString()
当然,这不是预期的结果,而 IE 不会这样做。 我缺少什么?
更新:
这是我能想到的唯一方法:
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(); }
I have a form in my winforms app that acts as a built-in browser. It uses the .net webbrowser control. 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. When I hover over the menu (using my browser form), the address bar changes to: http://domainname/WebResource.axd?etc/etc/etc, unexpectedly
I am trapping the webbrowser_navigating event and setting the Text property of the address bar to e.Url.ToString()
Of course, this is not the expected result, and IE doesn't do this.
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(); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅上面桑杰的评论。
See Sanjay's comment above.