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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Containing Folder 1

Status
Not open for further replies.

Borvik

Programmer
Jan 2, 2002
1,392
US
I have a project that is going to be distributed on USB drive, and would like to have a link that will open the containing folder (the root of the USB drive).

Because it's a USB drive, I can't hard-code the link - how might I be able to do this (if it's even possible)?

Thanks.
 
Not sure I fully understand, but..
You can open a file on a usb drive as long as the usb drive letter is the same as in your code. But as far as opening a asp web site, I don't think thats possible because its not a Web directory or a virtual dir. on IIS. IIS does not know what to do with it.

And of course the machine you put it on needs IIS.
 
Here is what's happening:

I have a custom action set for the USB drive, so upon inserting it - the default is to open the specified HTML file in Internet Explorer. This also makes the default double-click icon in "My Computer" open the file page as well.

In order to still allow easy access to the files on the USB drive - I want to provide a link on the page that will open up the drive. So for example, you insert the USB drive and your computer gives it the letter E. The web page opens up, and you click on the link. The contents of drive E are then opened in a new window.

I guess the biggest thing then is: using JavaScript - How can I detect the drive letter that the page is on?

Once I have the drive letter (in a JavaScript var), I should be able to just open a new window with that as it's location - right?
 
You can get the drive letter (such as x:) from this function. If return empty, it is not on the local file system with file:// protocol.
[tt]
function finddrive() {
var s=window.location.href; //do not omit .href
//use two slashes if you want op to behave as well
if ((/file:\/\//i).test(s)){
var t=s.split(/\//);
if (window.ActiveXObject) {
return t[1]);
} else {
return t[3]);
}
} else {
return ""; //not on local file system
}
}
[/tt]
 
Thanks tsuji!

That worked (after some modifications to using the RegEx object).
 
Thanks!
Just feel like to make a further note on the obvious typos of unwarranted surplus ")" after [green]return t[1][/green] or [green]return t[3][/green]. It would be obvious if one gets the idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top