Process.Start(url),url 中带有锚点
我正在尝试使用 Process.Start 在默认浏览器中启动本地 html 文件。
示例 url 如下:
"file:///C:/Documentation/HelpContent/default_CSH.htm#SectionA/Topic1.htm"
问题是,由于某种原因,“#SectionA/Topic1.htm”位被删除,因此该信息不会传递到浏览器。但对于非本地 url 来说它确实可以正常工作。
有谁知道我如何才能让它发挥作用,或者这是某种预防性安全问题?
谢谢
I am trying to use Process.Start to launch a local html file in the default browser.
An example url is as follows:
"file:///C:/Documentation/HelpContent/default_CSH.htm#SectionA/Topic1.htm"
Problem is, the "#SectionA/Topic1.htm" bit gets stripped off for some reason, so that this information isn't passed to the browser. It does however work fine for a non-local url.
Does anyone know how I can get this to work or is it some sort of preventative security issue?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
iexplore.exe
上使用Process.Start
,以便您可以专门指定 URL 作为其参数:Use
Process.Start
oniexplore.exe
, so that you can specify the URL specifically as its argument:如果您让操作系统确定默认浏览器,则在浏览器中启动带有锚点的 URL 将不起作用。实现此功能的唯一方法是将浏览器的可执行文件指定为为 IE 编写的二进制编码器。 Firefox 的工作方式相同。
最好的解决方案显然是从注册表中确定默认浏览器的路径,然后专门调用该可执行文件。
Launching a URL with an anchor in a browser does not work if you let the OS determine the default browser. The only way to make this work is to specify the browser's executable as binarycoder wrote for IE. It works the same way for Firefox.
The best solution is obviously to determine the path to the default browser from the registry and then specifically call that executable.