Standard HTML links are designed to navigate to web pages, not to open local folders. However, by leveraging some tricks, we can make links launch folder views.
Background:
The operating system dictates how URLs are handled, and Windows has two types of URL shortcuts:
Solution:
To open a local folder, we will create a downloadable .URL file with the following format:
<code class="text">[InternetShortcut] URL=file:///D:/</code>
Implementation:
<code class="html"><a href="URIShortcut.url">Open Folder</a></code>
By generating and providing downloadable .URL files for local folders, we can simulate folder opening functionality in HTML links. This solution works across major browsers, offering varying user experiences depending on the browser used.
The above is the detailed content of How Can We Open a Local Folder by Clicking a Link?. For more information, please follow other related articles on the PHP Chinese website!