Click to See Complete Forum and Search --> : Window.Open: Access Denied...


seantynan
07-10-2003, 12:07 PM
I get Access Denied when I use window.open().
The URL I am passing is to a file on my local machine:

C:\Stuff\Image1.jpg

I have a Preview button which allows users to view images on their local machine.

Does this mean that I can't window.open() to a local file? Or am I doing something wrong?

Please help!

TIA,

- Sean.

cacalex
07-10-2003, 01:05 PM
Are you using the window.open() to open an image ???

What is the purpose of it ???

Give me example of your code, and details on what you want to do, pls...

Khalid Ali
07-10-2003, 01:06 PM
It seems like u are suing a web server and the webserver asumes that you are trying to access a resource which is an out of domainresource...

seantynan
07-10-2003, 01:14 PM
I have a web page that allows users to upload an image:

<input type="file" name="FileName" size="25">

<INPUT class=button name=btn_Preview type=button value=Preview onclick="javascript: fOpenProductPreviewWindow(window.frmEditProduct.FileName.value)">

function fOpenProductPreviewWindow(strURL) {
//Open Preview window - Allows the CA users to preview images of products

var width = 350;
var height = 300;
x = (640 - width)/2, y = (480 - height)/2;
if (screen) {
y = (screen.availHeight - height)/2;
x = (screen.availWidth - width)/2;
}
var strOptions = 'toolbar=no,scrollbars=yes,menubar=no,location=yes,directories=no,,resizable=yes,width='+width+',hei ght='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x;

//If window already open, close and reopen window (with new data), else open window.
if (strURL != ''){
if (objProductPreviewWindow)
if (objProductPreviewWindow.closed)
objProductPreviewWindow = window.open(strURL,"", strOptions);
else
{
objProductPreviewWindow.close();
objProductPreviewWindow = window.open(strURL,"", strOptions);
}
else
objProductPreviewWindow = window.open(strURL,"", strOptions);
}
}

When people select a file, they then click on the Preview button to preview the image. When the image is located on the user's local machine, I get the Access Denied message.

Khalid Ali
07-10-2003, 01:16 PM
If I uderstand you correctly,your page is served from your webserver and then a client uploads a file from their local machine and try to see it..no way unless you have some temp folder on your webserver where you upload the images.

seantynan
07-10-2003, 01:21 PM
The user previews the file (an image) before uploading it.
The preview uses window.open() to open the file locally.

The URL passed to window.open() is the URL of the file itself, locally, e.g. C:\Stuff\Image1.jpg

The window.open() causes the Access Denied error.

Khalid Ali
07-10-2003, 01:39 PM
;)
Ya gotta read my responses..as I said if you are serving your page froma webserver then trying to open a page like that could constitute a breach of browser security paradigm,hence access denied

seantynan
07-10-2003, 01:52 PM
Why the security problem? I'm asking the browser to open a local file.

window.open(window.frmEditProduct.FileName.value)

FileName is a <input type="text"> that the user uses to select a *local* file.

I don't understand why that won't work.

Anyway, I think I'll try a different approach.
Maybe a web page that accepts the URL as a parameter, then inserts it into the src of an image tag...

Thank you all for your help.

- Sean.