window.open issue

J

JCCDevel

Hi All,

I am attempting to do something I thought would be simple. From one
of my asp.net pages, I need for the user to be able top open up
documents(any file format - .xls, .doc, .pdf, etc). To accomplish
this, I am using javascript:

<code>
<script type="text/javascript">
function open_win()
{
window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/
dbStylemaster.ppt')
}
</script>
</code>

I am getting "Access is Denied".

This file I am trying to open is on my hard drive and I am running the
asp.net program locally as I am developing. Eventually, the files
will be stored on a web server.

I have done a lot of searching this morning and am just more
confused. Am I attempting to do something that won't be allowed
because of security?

Thansk in advance for your help!

JCC
 
T

Thomas 'PointedEars' Lahn

JCCDevel said:
I am attempting to do something I thought would be simple. From one
of my asp.net pages, I need for the user to be able top open up
documents(any file format - .xls, .doc, .pdf, etc). To accomplish
this, I am using javascript:

<code>

This is Usenet. Please do not bother (us) with pseudo-tags.
<script type="text/javascript">
function open_win()
{
window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/
dbStylemaster.ppt')

For a proper file:// URI, you need to add another slash before the C: to
specify the local host. (The `localhost' host name after it is optional then.)

But this method only constitutes overhead.
}
</script>
</code>

I am getting "Access is Denied". ^^^^^^^^^^^^^^^^
This file I am trying to open is on my hard drive and I am running the
asp.net program locally as I am developing. Eventually, the files
will be stored on a web server.

I have done a lot of searching this morning and am just more
confused. Am I attempting to do something that won't be allowed
because of security?

That much would be obvious, would it not?

You are attempting to access a file:// resource from a http(s):// resource.
The client application does not care, because it cannot know, that both are
on the same machine. So access is denied.


PointedEars
 
L

Laurent vilday

Thomas 'PointedEars' Lahn a écrit :
This is Usenet. Please do not bother (us) with pseudo-tags.

This is Usenet. Don't talk in the name of the whole group, don't say
*us* there is no "us".

Talk in your OWN name, thanks.
 
W

wayne

window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/

You could write a tiny http "server" for the localhost, e.g. listening
on ip 127.0.0.1:80 then use URL of the form http://c/path where this
tiny server converts /c/path into c:\path to open and read whole file
into a buffer, then send it to the socket. I have done something like
that (also for code development) by rigging our existent http server
source (the iPhone remote desktop & file server, http://f2p.com ) with
that kind of custom file i/o. You can probably find some tiny http
server source on the web and spend few hours on customization. That
scheme also lets you dump js debug strings (e.g. via XMLHttpRequest)
to the console on the server side, without disrupting display on the
client side.
 
T

Thomas 'PointedEars' Lahn

wayne said:
You could write a tiny http "server" for the localhost, e.g. listening on
ip 127.0.0.1:80 then use URL of the form http://c/path where this tiny
server converts /c/path into c:\path to open and read whole file into a
buffer, then send it to the socket.

ISTM this server would listen, but would not hear anything. In this URI,
`c' would be the host name, and that is what would have to be defined in the
local `hosts' file as an alias for `localhost', as an alternative DNS record
would be either invalid or complicate maintenance.
I have done something like that (also for code development) by rigging
our existent http server source (the iPhone remote desktop & file server,
http://f2p.com ) with that kind of custom file i/o.

That was probably http://localhost/c/...
You can probably find some tiny http server source on the web and spend
few hours on customization.

I would probably use a very basic TCP sockets based service instead; I
hacked one together using a Java tutorial[1] in about one hour, about 120
LOC (pretty-printed). I had written almost no Java code before; if you can
write J(ava)Script, you can also write this one. (Eclipse, of course, came
in very handy :))

However, the OP already has a local server with ASP .NET; I recommend to use
the existing infrastructure instead.


PointedEars
___________
[1] Abts, Dietmar: Masterkurs Client/Server-Programmierung mit Java;
pp. 106; 2. Auflage; April 2007; Vieweg & Sohn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top