Hello,

I have a problem between different browser.

I have a link that directs to a folder that is shared within a localhost server and it works find with internet explorer, but it doesnt work with chrome or mozilla.

<a href='\\Server\folder\'>Click Here</a>

That is a simple code I have set up. Its not supposed to direct to a weblink but a folder that is being shared.

In chrome, the link doesnt do anything when I click on it. In firefox, it just directs me to a website error. In internet explorer, it works.

How do I make it work for all browsers?

Thank you

Dani AI

Generated

The difference in behavior is not a bug in the markup. Internet Explorer historically lets pages hand off UNC/file paths into the Windows shell, while Chrome and Firefox block requests to local files from pages served over HTTP/HTTPS for security. That is why sees the link work in IE but do nothing or show an error in Chrome/Firefox.

UNC paths must be expressed as file URIs when used in HTML. For example:

<a href="file://myserver/share/Folder%20Name/">Open share</a>

Or, if the share is mapped to a drive letter on the client:

<a href="file:///Z:/Folder%20Name/">Open mapped drive</a>

Note: spaces must be percent-encoded (%20). The exact file-URI rules are defined in the spec (RFC 8089) and URIs use forward slashes, not backslashes. See RFC 8089 for the file-URI format: RFC 8089: The "file" URI Scheme.

Practical, cross-browser solutions that avoid relying on IE-specific behavior:

  • Expose the folder via HTTP/WebDAV on the server (serve an index or directory listing). Linking to an http:// or https:// URL will work in all browsers.
  • Create a small server-side script that lists and serves files from the share (PHP/Node/Python), then link to that script.
  • In tightly controlled intranets, deploy a client-side helper (protocol handler or browser extension) that opens file/smb links — this requires installation on every client and should be used only in managed environments.

Troubleshooting tips: paste a file://... URL directly into the browser address bar to test whether the client can reach the share; open the page locally via file:// to see whether the browser allows local-origin links; and remember that single vs. double quotes in the HTML attribute does not change browser security policy. was right that HTML quoting style is mostly cosmetic; was correct that Windows UNC syntax differs from URL form.

Recommended Answers

All 5 Replies

Are you sure you didn't invert the slashes?

<a href="//Server/folder">Click Here</a>

Also, you should probably be using double-quotes instead of single-quotes.

its different because i'm not passing in an actual web link, its a directory path in a folder.

Also, I don't see why the quotes would matter?

andrewliu,

Also, the double quotes are typically used for HTML and single quotes used for PHP when echoing (thus avoiding the hard-to-read backslash double-quote escape).

As for Firefox having problems, have you tried clearing your cache? Or maybe its IE than needs the cache clearing?

Hmmm, i used the single quotes cause it was in php i had an echo "<a href='...


I will try that solution when I'm in the office. But if my code works for IE, it should work for other browsers right? I need to access a folder with a ahref link.

What is the server type 'nix or windows. This makes all the difference. If I need to mount any of my CIFS(samba shares) I use \\\\sharename\\folder with no trailing backslash. For windows I use \\sharename\folder. I hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.