我正在尝试从c#中打开Chrome中的网址并保留哈希值(#).例:
string command = "http://127.0.0.1/test.html#foobar";
ProcessStartInfo ps = new ProcessStartInfo(command) { UseShellExecute = true };
Process.Start(ps);
Run Code Online (Sandbox Code Playgroud)
启动进程后,包括哈希(#)在内的所有内容都将丢失.我可以从命令提示符手动运行Chrome,包括url中的哈希值
C:\ Program Files(x86)\ Google\Chrome\Application> 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>
Run Code Online (Sandbox Code Playgroud)
注意:我不想假设用户想要使用chrome,我需要它在用户默认浏览器中工作.当用户的默认浏览器是IE或Fire Fox时它可以工作,但是当用户默认浏览器是Chrome时,哈希就会丢失.