Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make 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 like this:

<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 both in IE and Firefox?

Edit The above link actually work if I put them in a local file. They stop working only in Firefox when they are part of a html file on the network (not on my machine). There must be some kind of security setting in Firefox that prevents file:/// links from working coming from external content?

like image 623
Anthony Brien Avatar asked May 01 '09 14:05

Anthony Brien


People also ask

How do you make a file linkable?

Create a hyperlink to a file on your computerSelect the text or picture that you want to display as a hyperlink. Press Ctrl+K. Under Link to, do one of the following: To link to an existing file, click Existing File or Web Page under Link to, and then find the file in the Look in list or the Current Folder list.

How do I create a link to a file in Internet Explorer?

Essentially, what you need to do is open File Explorer, navigate to the file, folder, or library you want to hyperlink, and right-click on it to see its context menu. Then, if you're on Windows 10, select “Give access to” and click or tap on Specific people.


2 Answers

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 info

like image 98
Ian G Avatar answered Oct 06 '22 00:10

Ian G


file Protocol
Opens a file on a local or network drive.

Syntax

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

sDrives
Specifies the local or network drive.

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

Remarks

The file protocol and sDrives parameter can be omitted and substituted with just the command line representation of the drive letter and file location. For example, to browse the My Documents directory, the file protocol can be specified as file:///C|/My Documents/ or as C:\My Documents. In addition, a single '\' is equivalent to specifying the root directory on the primary local drive. On most computers, this is C:.

Available as of Microsoft Internet Explorer 3.0 or later.

Note Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a local machine from the Internet zone. For instance, if an Internet site 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 the link to the local file.

Example

The following sample 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

like image 38
ArturasJ Avatar answered Oct 06 '22 00:10

ArturasJ