How to create a file: // hyperlink that works in both IE and Firefox?

In my documentation web pages, I often need to provide links to locations, files, and applications (.xbap) stored on the intranet.

In IE, this works fine with URLs formatted as follows:

<a href="file://///company.org/ProjectA/StatsReport">Go to folder</a> <a href="file://///company.org/ProjectA/Readme.txt">Download file</a> <a href="file://///company.org/ProjectA/Dashboard.xbap">Run xbap</a> 

These links all work fine under IE, but in Firefox they don't.

Does anyone know how I can format the above links to work in both IE and Firefox?

Edit The above link really works if I put them in a local file. They stop working only in Firefox when they are part of an html file on the network (and not on my machine). Does Firefox have to have some kind of security setting that prevents files from working: /// links from external content?

+7
firefox internet-explorer hyperlink
source share
6 answers

You can check this link or try using UNC paths.

+3
source share

just use

 file:/// 

works in IE, Firefox and Chrome, as far as I can tell.

see http://msdn.microsoft.com/en-us/library/aa767731(VS.85).aspx for more information

+6
source share
File protocol


Opens a file on a local or network drive.

Syntax

 Copy file:///sDrives[|sFile] Tokens 

sDrives
Specifies a local or network drive.

sFile
Optional. Specifies the file to open. If sFile is omitted and the account accessing the disk has permission to view the directory, a list of available files and directories is displayed.

Notes

The file option and sDrives can only be omitted and replaced with a command line representation of the drive letter and file location. For example, to view the My Documents directory, a file can be specified as a file: /// C | / My documents / or as C: \ My documents. In addition, the single '\' is equivalent to specifying the root directory on the main local disk. On most computers, this is C :.

Available as in Microsoft Internet Explorer version 3.0 or later.

Note. Internet Explorer 6 Service Pack 1 (SP1) no longer allows you to view the local machine from the Internet zone. For example, if a website contains a link to a local file, Internet Explorer 6 SP1 displays a blank page when a user clicks on the link. Previous versions of Windows Internet Explorer followed a link to a local file.

Example

The following example demonstrates four ways to use the File protocol.

Copy

 //Specifying a drive and a file name. file:///C|/My Documents/ALetter.html //Specifying only a drive and a path to browse the directory. file:///C|/My Documents/ //Specifying a drive and a directory using the command line representation of the directory location. C:\My Documents\ //Specifying only the directory on the local primary drive. \My Documents\ 

http://msdn.microsoft.com/en-us/library/aa767731

+2
source share

If someone else finds this topic when using localhost in a file URI - Internet Explorer acts quite differently if the hostname is localhost or 127.0.0.1 - if you use the actual hostname, it works fine (from trusted sites / intranet zone).

Another big difference between IE and FF-IE is fine with uris like file://server/share/file.txt , but FF requires additional file:////server/share/file.txt .

0
source share

Paste the following link directly into the link by clicking the click button, otherwise use javascript to call the code for the function

 Protected Sub lnkOpen_Click(ByVal sender As Object, ByVal e As EventArgs) System.Diagnostics.Process.Start(FilePath) End Sub 
0
source share

At least with Chrome (I don't know about Firefox). You can drag the icon to the left of the browser URL into a folder on your desktop and create a file that behaves like an Internet shortcut.

I don't know if the file format is universal, but Chrome seems to know what to do with it.

The .url file is a .url file and contains the following:

[InternetShortcut] URL=http://www.accordingtothescriptures.org/prophecy/353prophecies.html

You can replace the URL with anything.

0
source share

All Articles