5

When I try to open window.open('file///C:\calendar.html') it throws

Access Denied error

How do I fix this? Thanks

2
  • 2
    What is the context? Where is this Javascript code located?
    – Pointy
    Commented Nov 22, 2010 at 15:22
  • Are you going to accept one of the answers below? :D *jumps* Commented Dec 22, 2010 at 13:30

2 Answers 2

4

Usually you'll won't be allowed to open files from the client's filesystem as this would pose a huge security hole. No browsers would allow it.

You could use signed scripts to do that. For a detailed description check: http://www.mozilla.org/projects/security/components/signed-scripts.html This is of course browser specific.

2
  • 1
    Why is it a security hole? The browser is trying to open a program in your local PC. I dont get it.
    – karlihnos
    Commented Jan 10, 2017 at 9:34
  • 1
    Because any attacker could write javascript that runs on the victim's computer, reads confidential files and sends the content to the attacker. Commented Jan 10, 2017 at 10:03
4

Could it be that the colon is missing?

'file:///C:\calendar.html'

Edit: Might also need to do only two forward slashes, and escape the backslash: 'file://C:\\calendar.html'. Not sure you can open local files via JavaScript though, like the other answer says.

Not the answer you're looking for? Browse other questions tagged or ask your own question.