"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Open Local Directories as Hyperlinks?

How to Open Local Directories as Hyperlinks?

Published on 2024-11-05
Browse:190

How to Open Local Directories as Hyperlinks?

Navigating Local Directories via Hyperlink

While attempting to initiate a local directory view upon link interaction, you may encounter limitations. However, there is a solution that addresses this issue and works seamlessly across various browsers.

Implementation Methodology

Since direct path opening or explorer launch from an HTML page is restricted for security reasons, a more feasible approach involves providing a downloadable link (.URL or .LNK).

Recommended Path: .URL

.URL files, being text-based, are dynamically generatable. To implement this solution:

  1. Ensure that your web server supports the .url MIME type.
  2. Craft a .url file with the following content:
[InternetShortcut]
URL=file:///D:
  1. Provide a link to either the dynamically generated .url script or the .url file itself in your HTML:

    Round-About Linking

Browser-Specific Behavior

  • Chrome: Prompts download of file.url, then opens it. This behavior can be optimized by enabling "Always open files of this type."
  • Firefox: Similar to Chrome, file.url is downloaded and subsequently opened.
  • Internet Explorer: No need to save a shortcut; clicking "Open" directly accesses the specified directory.
Release Statement This article is reprinted at: 1729564515 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3