Home > Web Front-end > JS Tutorial > body text

How to Open Local Directories as Hyperlinks?

Barbara Streisand
Release: 2024-10-22 10:48:02
Original
350 people have browsed it

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:
<code class="txt">[InternetShortcut]
URL=file:///D:</code>
Copy after login
  1. Provide a link to either the dynamically generated .url script or the .url file itself in your HTML:

    <code class="html"><a href="URIShortcut.url">Round-About Linking</a></code>
    Copy after login

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.

The above is the detailed content of How to Open Local Directories as Hyperlinks?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!