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

Javascript Server.MapPath Equivalent

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

You know how we can do Server.Mappath(" ") to get the location of the current page?

Is there a way that you know of to do it in javascript?

I have a button, and when its clicked I want it to go out two folder levels and get to a file there. the usual
..\..\ doesn't work though (keeps trying to go to the current path and add that on). Funny thing is that if I just put a file thats in the same directory, it works no problem.

Thanks,

jack
 
You could always used mixed script. For instance, to get the physical path of the parent folder of the page you're on into a javascript var:

<script language=javascript>
var rootPath = '<%=Server.MapPath(&quot;../&quot;)%>';
</script>

which will render like:

<script language=javascript>
var rootPath = 'd:\inetpub\</script>

Should be pretty easy to modify to suit your needs.

hth :)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top