c# - 打开一个 Internet Explorer Windows,其中只有 3 个选项卡

标签 c# internet-explorer firefox shdocvw

我正在和一个同事一起做一个项目,我们一直在办公 table 前绞尽脑汁想弄清楚这个问题。我们的要求是让一个新的 Internet Explorer 浏览器弹出一个网页,然后向其附加两个选项卡。我们找到了一个可以在我同事的电脑上运行的解决方案,但是当我们在我的电脑和另一位同事的电脑上尝试时,它不起作用。我们目前拥有的:

using SHDocVw;

...

ShellWindows iExplorerInstances = new ShellWindows();    
Process.Start("IExplore.exe", "www.reddit.com");
Thread.Sleep(5000);
string url = "http://www.google.com";
IEnumerator enumerator = iExplorerInstances.GetEnumerator();
enumerator.MoveNext();
InternetExplorer iExplorer = (InternetExplorer)enumerator.Current;
iExplorer.Navigate(url, 0x800); //0x800 means new tab 
url = "http://www.banana.com";
enumerator = iExplorerInstances.GetEnumerator();
enumerator.MoveNext();
iExplorer = (InternetExplorer)enumerator.Current;
iExplorer.Navigate(url, 0x800); //0x800 means new tab 

同样,这只能在他的计算机上正常工作。对我来说,当我尝试运行此代码时,它会正确打开 Internet Explorer 浏览器,但即使我使用的是 InternetExplorer 对象,它也会在 Firefox 中打开选项卡。我深入研究了类并尝试打印出我能找到的任何有用的东西。我的 InternetExplorer 对象中的名称属性是“Windows 资源管理器”。我详细了解了 ShellWindows 的实际作用,这很有意义,但对我没有帮助。这似乎暗示它通过 InternetExplorer 对象而不是 Internet Explorer 打开我的默认浏览器。我的同事将 Chrome 作为默认浏览器,结果也不同。我将我的默认浏览器切换到 Chrome 以查看是否是问题所在,但随后在 Chrome 中打开了两个额外的选项卡。我真正需要的只是打开一个 Internet Explorer 浏览器,其中有 3 个选项卡,每个选项卡都有自己的 URL。非常感谢任何帮助。

最佳答案

看起来这个人有您正在寻找的解决方案:

Launch a URL in a tab in an existing IE window from C#

关于c# - 打开一个 Internet Explorer Windows,其中只有 3 个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13404780/

相关文章:

C# 如何设计面板供以后使用..(设置屏幕)

c# - Azure 应用服务 File.ReadAllText 返回文件未找到异常,但文件存在于该位置

css - 添加了 Sass、IE 过滤器和额外的空格

javascript - Firefox 37 上 console.log() 的奇怪行为

android - Google Places Autocomplete 插件无法在 Firefox android 中运行

c# - 相交两层并获得结果特征

c# - asp.net mvc api返回 'This XML file does not appear to have any style information associated with it. The document tree is shown below.'

css - Internet Explorer 兼容的 CSS 过滤器生成器

javascript - appendChild 无法在 IE 中使用 window.open

javascript - 需要帮助使用 Firebug 记录函数体