1

i am opening a file in IE6.0 from a directory using JavaScript. but iam getting 'Access is denied' error in javascript.My code in javascript

function poponload()
{
testwindow = window.open("C:\Searchtool\asd1.wrl", "mywindow", "location=1,status=1,scrollbars=1,width=300,height=300");
testwindow.moveTo(0,0);
}

if i use the same function from plain html page it is opening the page. But if i try to do the samething from ASP.NET2008(.ASPX page), i am getting 'access is denied' error. can anybody tell the reason why it is giving error? and Solution?

Thanks

4 Answers 4

6

You are trying to access a file on the hard drive which you aren't allowed to do from a page from a web server.

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

1 Comment

For more information, look up the "Same Origin Policy": en.wikipedia.org/wiki/Same_origin_policy
2

It's a browser security feature. It won't allow you to directly access the hard drive from a web page. You can access it when you open an HTML file on the local system -- since the browser isn't granting you any more abilities than you already have, but allowing a web page to open a file on a local hard drive would be a huge security flaw.

The only way I know to do things like this are through trusted plugins/applets -- such as ActiveX or Java Applets. These need to be signed and/or have the user explicitly trust them with access to your system to get them to work.

Comments

0

If you are learning html and want a way to open pages in your machine from pages in your machine:

window.open("file:///C:/Searchtool/asd1.wrl", "mywindow", "location=1,
    status=1,scrollbars=1,width=300,height=300");

2 Comments

Isn't this possible? Since you can open local pages with file:/// protocol, I thought it would go well in script too - didn't bother to test it.
Just tested it and it is possible - why the down-vote then? I specifically said that this can be used only to open pages in your machine from pages in your machine.
0

better, put files in the same directory where is your web page.

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.