Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在IE的新选项卡中打开网页,即使它是';它不是默认的浏览器 背景_C#_Internet Explorer_Process - Fatal编程技术网

C# 在IE的新选项卡中打开网页,即使它是';它不是默认的浏览器 背景

C# 在IE的新选项卡中打开网页,即使它是';它不是默认的浏览器 背景,c#,internet-explorer,process,C#,Internet Explorer,Process,我们正在开发一个应用程序,你可以在互联网上搜索一些东西或打开一个网页,你也可以选择使用什么浏览器 例如,如果我想打开Google.com,我希望它在Chrome中打开,那么网页应该在Chrome中打开。如果我想在IE中打开Google.com,那么IE应该打开Google页面 关于在浏览器中使用选项卡:由于现在所有浏览器都支持它,因此在新选项卡中打开网页已经由浏览器本身负责,无论是Chrome还是Firefox。但是在IE的情况下,如果IE是您的默认浏览器,那么IE将在新的IE选项卡中打开该网页

我们正在开发一个应用程序,你可以在互联网上搜索一些东西或打开一个网页,你也可以选择使用什么浏览器

例如,如果我想打开Google.com,我希望它在Chrome中打开,那么网页应该在Chrome中打开。如果我想在IE中打开Google.com,那么IE应该打开Google页面

关于在浏览器中使用选项卡:由于现在所有浏览器都支持它,因此在新选项卡中打开网页已经由浏览器本身负责,无论是Chrome还是Firefox。但是在IE的情况下,如果IE是您的默认浏览器,那么IE将在新的IE选项卡中打开该网页。但是,如果IE不是您的默认浏览器,那么IE将在新的IE窗口中打开网页

一些补充资料 打开网页有几种方法 通过: 默认web浏览器的代码

Process.Start(new ProcessStartInfo()
{
    FileName = "http://www.google.com"
});
或者,如果您想在默认Web浏览器之外的其他Web浏览器中打开该网页。比如Firefox

string a = "%programfiles%\\Mozilla Firefox\firefox.exe";
a = Environment.ExpandEnvironmentVariables(a);

Process.Start(new ProcessStartInfo()
{
    FileName = a,
    Arguments = "http:\\www.google.com"
});
命令

>start "http://www.google.com"

cmd/c开始“”

问题:
即使IE不是您的默认浏览器,您如何在新选项卡上打开IE(版本8、9和10)中的网页?

如果您打算使用Internet Explorer进行此操作,您可以这样做:

创建一个名为
temp.js
的(临时)脚本文件。把这个放进去:

var navOpenInBackgroundTab = 0x1000;
var objIE = new ActiveXObject("InternetExplorer.Application");
objIE.Navigate2(FIRST TAB URL GOES HERE);
objIE.Navigate2(SECOND TAB URL GOES HERE, navOpenInBackgroundTab);
objIE.Navigate2(NTH TAB URL GOES HERE, navOpenInBackgroundTab);
objIE.Visible = true;
然后在创建脚本的目录中调用该脚本:
wscript temp.js

以后不要忘记删除它:


哦,如果这听起来像是一个可怕的黑客行为,相信我:确实如此。

如果您打算使用Internet Explorer来实现这一点,您可以这样做:

创建一个名为
temp.js
的(临时)脚本文件。把这个放进去:

var navOpenInBackgroundTab = 0x1000;
var objIE = new ActiveXObject("InternetExplorer.Application");
objIE.Navigate2(FIRST TAB URL GOES HERE);
objIE.Navigate2(SECOND TAB URL GOES HERE, navOpenInBackgroundTab);
objIE.Navigate2(NTH TAB URL GOES HERE, navOpenInBackgroundTab);
objIE.Visible = true;
然后在创建脚本的目录中调用该脚本:
wscript temp.js

以后不要忘记删除它:


哦,如果这听起来像是一个可怕的黑客行为,相信我:的确如此。

Windows理解注册表中任何条目的速记:

HKEY_LOCAL_MACHINE
   SOFTWARE
       Microsoft
           Windows
               CurrentVersion
                   App Paths
因此,假设浏览器安装没有问题,每个客户端都会有如下条目:

  • Firefox.exe
  • IEXPLORE.exe
  • Chrome.exe
也就是说,你实际上可以使用这种东西:

Process.Start(new ProcessStartInfo()
{
    FileName = "firefox.exe",
    Arguments = " \"http://www.google.com\""
});

Process.Start(new ProcessStartInfo()
{
    FileName = "iexplore.exe",
    Arguments = " \"http://www.google.com\""
});

Process.Start(new ProcessStartInfo()
{
    FileName = "chrome.exe",
    Arguments = " \"http://www.google.com\""
});

。。从而针对特定浏览器。

Windows理解注册表中任何项目的速记:

HKEY_LOCAL_MACHINE
   SOFTWARE
       Microsoft
           Windows
               CurrentVersion
                   App Paths
因此,假设浏览器安装没有问题,每个客户端都会有如下条目:

  • Firefox.exe
  • IEXPLORE.exe
  • Chrome.exe
也就是说,你实际上可以使用这种东西:

Process.Start(new ProcessStartInfo()
{
    FileName = "firefox.exe",
    Arguments = " \"http://www.google.com\""
});

Process.Start(new ProcessStartInfo()
{
    FileName = "iexplore.exe",
    Arguments = " \"http://www.google.com\""
});

Process.Start(new ProcessStartInfo()
{
    FileName = "chrome.exe",
    Arguments = " \"http://www.google.com\""
});

。。因此针对特定浏览器。

假设firefox位于“%programfiles%\\Mozilla firefox\firefox.exe”不是一个好主意。重复@RobertMcKee的问题-谢谢!看来又是一个光明的日子了,假设firefox将位于“%programfiles%\\Mozilla firefox\firefox.exe”不是一个好主意。重复@RobertMcKee的问题-谢谢!看起来又是一个光明的日子等待解决方案看起来不安全,但看起来很有帮助。我会给它一个尝试的解决方案看起来不安全,但看起来很有帮助。我试试看