How to open local .htm file with anchor(#) link in

2019-07-12 14:09发布

I try to open local .htm file with anchor link in Edge browser from command linе.

LaunchWinApp.exe "file:///C:/index.htm#anchor.htm"

But Edge browser opens only index page file:///C:/index.htm without additional page.

Why is this happening?

1条回答
走好不送
2楼-- · 2019-07-12 14:54

For the time being, you cannot open local files in this manner. You should instead host a web-server out of your target folder, and access the resources via localhost.

There are currently discussions taking place within the Microsoft Edge team around this topic, and what we may be able to do that would greatly improve the experience for developers like yourself.

If/when we make a change, impacting this issue, I'll return to update this answer. However, for the time being, your best option is to host a local server. Instructions for doing so using npm and Node.js are provided below.

If you're unsure how to stand up a local server, following these steps:

  1. Install the latest version of Node.js
  2. Open a command prompt, and run npm install -g http-server
  3. Navigate to your website folder, and Shift+Right Click to select Open command window here
  4. Run the command http-server

There is a GIF of the process online.

查看更多
登录 后发表回答