spiderplant0
spiderplant0

Reputation: 3952

Loading a local page into Firefox with Javascript

For loading a local file into Firefox I have noticed that...

location.href = "./relative/path/file.htm";  //this works
location.href = "http://localhost/path/file.htm";   //this works
location.href = "file:///c:/absolute/path/file.htm"; //doesnt work (also doesnt work if remove the "file:///" bit)

I would like to get the last example to work. Is there some about.config setting I can add to allow this or maybe a "netscape.security.PrivilegeManager..." statement?

(This is for a special Firefox profile and not for general use so the insecurity issues are not relevant). Thanks.

Upvotes: 0

Views: 306

Answers (2)

Liran
Liran

Reputation: 611

when using "file:///" you need to use backslashes ( windows ) in other words you need to type the physical address of the file as it accessed from file explorer ( windows )

dont forget escape with "\\".

example:

    var url = "file:///c:\\myDir\\1.html";

Upvotes: 0

Related Questions