file: URL (Request method)

Loads a local file into a window.

This request method is useful for retrieving files from the local file system, or can be used to display a window containing the HTML version of a directory in the client machine.

The file path values are platform dependent although web browsers tend to understand Unix path rules and convert them to the local platform specific conventions, although MSIE doesn't do this quite as well when navigating local file systems.

On MSIE for Windows, you must at least specify a disk drive letter because the Unix root directory is not mapped. This presents network mapped drives and removable media all at the same peer level. So start with this:

file:c:\

MSIE is so well integrated into the Windows environment that it immediately recognizes that you are browsing the file system and goes into desktop explorer mode. This adds a folder icon to the toolbar and you can then navigate exactly as you would from the desktop.

The web browsers attempt to take this functionality across to other platforms and so on the Macintosh, with MSIE, try this:

file:/

MSIE version 5.0 does a much better job and is aware of local network zones and can see other machines connected via the AppleTalk protocol. Given that you can satisfy the security requirements, you can browse a network of machines and keep shared documents on a workgroup server. On the Macintosh MSIE does a better job if the Finder has already mounted a shared volume on the desktop.

Using this technique you can also run applications provided the URL resolves to the name of an executable file. On Windows 98, this URL fires up the desktop calculator:

file:C:\Windows\Calc.exe

This means you can build a link on your page that activates local applications really easily. This works across platforms too. On the Macintosh, a functionally equivalent URL would be:

file://G3/APPS/Desk%20tools/Calculator%207.5

You may need to explore your hard disk to work out the paths to your installed applications. Don't forget that you need to use escaped URL values.

The same automated activation works for documents too. For example, locate an Excel spreadsheet and link to it from a document. When you click on the link, this will open Excel and load the document into it.

Older versions of Netscape Navigator are less capable of navigating the whole file system and initially start at the folder the browser application lives in. Netscape 6.0 exhibits a bug and this whole area of the browser needs more work before it is useful.

Accessing these capabilities from script is a little more tricky. window.location.href assignment effectively does the same thing on a Macintosh. On Windows, there are already capabilities for activating applications via the ActiveXObject and you need to use that technique because window.location.href does not like having applications loaded into browser frames.

Warnings:

See also:javascript: URL, URL, view-source: URL