我想在c#中打开Chrome中的网址并保留哈希(#)。 实施例:c#在哈希中打开网址(#)
string command = "http://127.0.0.1/test.html#foobar";
ProcessStartInfo ps = new ProcessStartInfo(command) { UseShellExecute = true };
Process.Start(ps);
后一切以及包括该井号(#)被启动进程时丢失。我可以包括在URL中的散列从命令提示符手动运行的Chrome
C:\ Program Files文件(x86)的\谷歌\浏览器\应用程序>的chrome.exe 127.0.0.1/test.html#foobar
当默认浏览器设置为IE或FireFox时,哈希值将保留。
任何建议,非常感谢。谢谢!
的test.html:
<!DOCTYPE HTML>
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<div style="height:1000px; background: #ccc; width: 100%"></div>
<a name="foobar">foobar</a>
</body>
</html>
注:我不想设定用户想要使用Chrome,我需要这在以往用户的默认浏览器是什么工作。当用户的默认浏览器是IE或Fire Fox时,它可以工作,但当用户默认浏览器是Chrome时,散列会丢失。
尝试在命令中显式运行Chrome吗? –