如何强制Web浏览器控件总是打开的网页在同一个窗口?(How to force Web Browser control to always open web page in the same window)

   IT问题网   2019-05-28 00:00:00

问 题

我需要使用web浏览器在我的应用程序,因为它使重复任务的员工,但没有与javascript的一个问题,点击锚后打开ie浏览器中的一个新窗口。我如何告诉网络浏览器控制"在新窗口打开",我希望它被打开?例如,在其他的网络浏览器控制?

解决方案

退房:的证明了概念.net system.windows.forms.webbrowser模块的使用源$ c $ c


我的有关控制的经历给了我的视野,这个问题可以尝试在接下来的步骤来解决:

  1. 随时取消 newwindow 事件

  2. 抓所有链接点击

  3. 但不是所有的链接可以被缓存这样,所以我决定来解析所有的标签 a 手动<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentcompleted.aspx"相对="nofollow">文件加载完成

  4. 在一般情况下,这种控制是非常差,目前已经取得微软刻意。虽然有各地 webrowser.document.htmldocument功能强大的工具集和命名空间 mshtml

  5. 的它的使用的一个例子是的 htmlelement.domelement

     的foreach(的htmlelement在webbrowser.document.all标签)
    {
    开关(tag.tagname.toupper)
    {
    案"a":
    {
    tag.mouseup + =新htmlelementeventhandler(link_mouseup);
    打破;
    }
    }
    }
    
    无效link_mouseup(对象发件人,htmlelementeventargs e)
    {
    的htmlelement链接=(htmlelement元素)发送;
    mshtml.htmlanchorelementclass a =(mshtml.htmlanchorelementclass)link.domelement;
    开关(e.mousebuttons pressed)
    {
    案例mousebuttons.left:
    {
    如果((a.target = null和放大器;!&安培; a.target.tolower()=="_blank")||
    e.shiftkey pressed ||
    e.mousebuttons pressed == mousebuttons.middle)
    {
    //添加新标签
    }
    其他
    {
    //在当前标签页中打开
    }
    打破;
    }
    案例mousebuttons.right:
    {
    //显示上下文菜单
    打破;
    }
    }
    }
     

查看更多在第一个环节,那就是主窗口的来源$ c $ c,有很多不同的手法在那里!

标签:如何强制强迫浏览器控件总是老是打开网页同一个



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

ASP.NET AJAX进度条:从code背后更新?(ASP.NET AJAX Progress Bar: Update from Code Behind)

problem i have an import function for an exce ...

为什么会发生这种code锁定我的文件?(why does this code lock my files)

problem ive narrowed down to this method but i don't unde ...

我怎么能转换成一个.net日期时间为T-SQL日期时间(How can I convert a .Net Datetime to a T-SQL Datetime)

problem mydatasource.selectparameters["startd ...

的WinForms MenuStrip中带下划线的热键信(Winforms MenuStrip Underlined Hotkey Letter)

problem typically the hotkey letters on a menustrip are u ...

如何找到一个控制的可见部分?(How do I find the visible part of a control)

problem i have a control whose parent is a scrollablecont ...

如何学习MVC - *未在Web设置*(How to learn MVC -- *not* in a web setting)

problem i wish to learn the mvc paradigm and apply it to ...

如何实现在一个DataReader偷看()函数?(How do I implement a Peek() function on a DataReader)

problem there doesn't seem to be a peek method on the dat ...

从.NET应用程序生成使用模板HTML(Generating HTML using a template from a .NET application)

problem i have a .net console application that needs to g ...

托管扩展性框架(MEF)与复合UI应用程序块(CAB)(Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB))

problem we are currently looking at either using cab or m ...

.tlh 2机产生的是不同的(.tlh generated on 2 machines is different)

problem i have a .net dll which has some interfaces\class ...

如何调整&QUOT;是一种类型,但使用像变量&QUOT;?(how to adjust &quot;is a type but is used like a variable&quot;)

problem i'm trying to generate some code in a ...

我可以模拟在.NET不同的Active Directory域中的用户?(Can I impersonate a user on a different Active Directory domain in .NET)

problem i have two active directory domains, a and b.user ...

IDisposable接口,终结和非托管资源的定义(IDisposable, Finalizers and the definition of an unmanaged resource)

problem i'm trying to make sure that my understanding of ...

如何使用。NET在Windows上构建iPhone应用程序?(How to build iphone apps using .Net on windows)

problem are there any tools (emulators, ide) which can he ...

编程参考任何人?(Programming References Anyone)

problem since i started working i go to stack ...

有没有实现在.net中的专有连接池的标准方法?(Is there a standard way of implementing a proprietary connection pool in .net)

problem is there a standard connection pooling model (or ...

什么是正确的方式来处理代理自动配置脚本,以在.NET中Web服务调用?(What&#39;s the right way to handle a proxy autoconfig script to make a webservice call in .net)

problem i'm using .net 2.0 to make a simple webservice ca ...

.NET MenuStrip中使用本机窗口渲染?(.NET MenuStrip with native Windows renderer)

problem does anyone know how to have the menustrips to re ...

如何将两个前pressions:结果= EXP1(EXP2);(How to combine two expressions: result = exp1(exp2);)

problem as subject, how to combine two expres ...

我可以放心地依靠的IsBackground在线程当应用程序终止?(Can I safely rely on IsBackground in Threads when the application terminates)

problem i'm running some background threads i ...