You need to use the file:/// protocol (yes, that's three slashes) if you want to link to local files.
<a href="file:///C:\Programs\sort.mw">Link 1</a>
<a href="file:///C:\Videos\lecture.mp4">Link 2</a>
These will never open the file in your local applications automatically. That's for security reasons, and I'll get to that in the last section. If it opens, it will only ever open in the browser. If it your browser can display the file, it will. If it can't, it will probably ask you if you want to download it.
Some browsers, like modern versions of Chrome, will even refuse to cross from the http protocol to the file protocol, so you'd better make sure you open this locally using the file protocol if you want to do this stuff at all.
The first part of a URL is the protocol. A protocol is a few letters, then a colon and two slashes. HTTP:// and FTP:// are valid protocols; C:/ isn't and I'm pretty sure it doesn't even properly resemble one.
C:/ also isn't a valid web address. The browser could assume it's meant to be http://c/ with a blank port specified, but that's going to fail.
Your browser may not assume it's referring to a local file. It has little reason to make that assumption, because public sites usually don't attempt to link to peoples' local files.
So if you want to access local files: tell it to use the file protocol.
Because it's part of the File URI scheme. You have the option of specifying a host after the first two slashes. If you skip specifying a host, it will just assume you're referring to a file on your own PC. In other words: file:///C:/etc is a shortcut for file://localhost/C:/etc.
Your browser will respond to these files the same way they'd respond to the same file anywhere on the internet. These files will not open in your default file handler (e.g. MS Word or VLC Media Player), and you will not be able to do anything like ask File Explorer to open the file's location.
Sites in your browser cannot interact with your operating system very well. If a good site could tell lecture.mp4 to open in VLC.exe, a malicious site could tell it to open virus.bat in CMD.exe. Or it could just tell your PC to run a few Uninstall.exe files, or to open File explorer a million times.
This may not be convenient for you, but HTML and browser security weren't really designed for what you're doing. If you want to be able to open lecture.mp4 in VLC.exe, consider writing a desktop application instead.
Thanks Jonathan. Do you know if there's a way to "show file in folder" as an alternative?
@Brian Your browser can't interact with your OS in that way, and you should be extremely glad it cannot.
Seems like Chrome won't download local files using the file:/// protocol anyway (giving you a Not allowed to load local resource error)
I want to give a link like this "file:///..\..\sort.mw" so that it goes back two folders and gets the file there. Because we are using the word file in dropbox. So is there any solution.
It might also worth mentioning you can not link from a website (e.g. local dev server) to a local file. forums.mozillazine.org/viewtopic.php?f=9&t=1730