6

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? 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.

Sign up to request clarification or add additional context in comments.

3 Comments

Why is it a security hole? The browser is trying to open a program in your local PC. I dont get it.
Because any attacker could write javascript that runs on the victim's computer, reads confidential files and sends the content to the attacker.
@IoanAlexandruCucu, this also applies when the user runs JS in the inspection console, though.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.