Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript, Windows XP, Local Hard Drive

Status
Not open for further replies.

rtype17

Programmer
Aug 12, 2002
9
US
I have written a page to be put on our website. The user goes to the webpage where they enter in a username, password, ftp site, and local hard drive. When they press 'Connect', two explorer windows open up with one viewing their local hard drive and the second viewing the ftp site. This is to provide users with and easy interface to ftp files without emailing them to us.

Anyways, when i developed the page on my hard drive (before i move it over to the webserver) it worked fine and both explorer boxes opened up. However, when i moved the webpage over to the server and tried to log on using the page it says 'Error on page' in the status bar and the local hard drive explorer window will not open. Secondly, i notice that everything works fine in versions of windows 2000 and below. So i am wondering if there is a setting in XP that will not allow javascript to view the drive of a local computer.

The code below:

window.open(local,'_blank', 'toolbar=yes,location=yes....

Where 'local' is a variable that will contain the local drive (ex: C:\) is supposed to open the explorer window viewing your local hard drive but errors out here.

Please help...

 
make sure you escape backslashes in the file name, so that

c:\folder\file.html

becomes

c:\\folder\\file.html



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Sorry, Jem, it didn't work. I have looked everywhere and can't seem to find a fix.
 
Is there a yellow icon next to where it says "Error on page"? If so, double-click it and tell us what the error message is. Also, it'd help if you posted a little more of your code.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Here's the code from the javascript file, .js. sorry it looks like crap on here. i am putting the line numbers on here to make it easier to read...

1: function Login(form) {
2: var username = form.username.value;
3: var password = form.password.value;
4: var server = form.server.value;
5: var local = form.local.value;
6: if (username && password && server && local) {
7: window.open(local,'_blank', 'toolbar=yes,location=yes,status=yes,scrollbars=auto,copyhistory=no,menubar=no,width=' + ((screen.AvailWidth/2)-12) + ',height=' + (screen.AvailHeight-124) +',left=0,top=0,resizable=yes');
8: window.open("ftp://" + username + ":" + password + "@" + server, '_blank', 'toolbar=yes,location=yes,status=yes,scrollbars=auto,copyhistory=no,menubar=no,width=' + ((screen.AvailWidth/2)-12) + ',height=' + (screen.AvailHeight-124) +',left=' + ((screen.AvailWidth/2)) + '),top=0,resizable=yes');
9: }
10: else {
11: alert("NO BLANK FIELDS!");
12: }
13: }

But anyways, clicking on the yellow icon next to "Error on Page" showed the following...

Line: 8
Char: 13
Error: Access is denied.
Code: 0

I put in alert statements and found it was not executing the line 7.

Again, this works fine on 2000 machine... thanks, guys.
 
Well I tweaked your code a little bit and it worked fine for me.
Code:
<SCRIPT LANGUAGE=javascript>
function Login(form) {
    var username = form.username.value;
    var password = form.password.value;
    var server = form.server.value;
    var local = form.local.value;
    if (username && password && server && local) {
            window.open(local,'_blank', 'toolbar=yes,location=yes,status=yes,scrollbars=auto,copyhistory=no,menubar=no,width=' + ((screen.AvailWidth/2)-12) + ',height=' + (screen.AvailHeight-124) +',left=0,top=0,resizable=yes');
            window.open("ftp://" + [b]escape(username)[/b] + ":" + [b]escape(password)[/b] + "@" + server, '_blank', 'toolbar=yes,location=yes,status=yes,scrollbars=auto,copyhistory=no,menubar=no,width=' + ((screen.AvailWidth/2)-12) + ',height=' + (screen.AvailHeight-124) +',left=' + ((screen.AvailWidth/2)) + '),top=0,resizable=yes');
            }
         else {
             alert("NO BLANK FIELDS!");
             }
     }
</SCRIPT>
<form onsubmit="Login(this);return false"><pre>
UserName <input name="username">
Password <input name="password">
Server   <input name="server">
Local    <input name="local">
         <input type=submit value="Login">
</form>

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
adam101,

Although your code does work for opening the ftp site, it's the local hard drive giving me the Access Denied that's the problem.

window.open(local,'_blank', 'toolbar=yes,location=yes,status=yes,scrollbars=auto,copyhistory=no,menubar=no,width=' + ((screen.AvailWidth/2)-12) + ',height=' + (screen.AvailHeight-124) +',left=0,top=0,resizable=yes');

If i // out the line above, the script will open the ftp site. but it doesn't want to give me access to my drive over the net. i am about to check our firewall to see it it's causing the problem.
 
>> "it doesn't want to give me access to my drive over the net"

sounds like a security hole. if this worked but doesn't now, it's probably been patched.

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top