1
votes

i am trying to get the current working directory path using JavaScript

when i execute from ubuntu: $root@ubuntu:/var/test/geek# firefox /var/www/application/test.html i get /var/www/application in my alert box instead of /var/test/geek in my alert box

used javascript code:

var path=window.location.pathname
 alert(path);

above code gives path of test.html

editing: Is it possible using perl script? perl-cgi?

after knowing that it is not possible from javascript, tried it using perl script.

my $pwd=cwd();

and running the perl script from html :

when i execute from ubuntu: $root@ubuntu:/var/test/geek# firefox /var/www/application/test.html

i still get /var/www/application in page instead of /var/test/geek. is it possible from perl?

1
window.location.pathname returns the path of the page loaded. you cannot get the path on the user's machine (that is a security risk) - bansi

1 Answers

0
votes

I suggest not to rely on this. The pathname you got might not be the actual path. Most of the time, developers uses the routing to hide actual path.

The Actual directory structure might be something like"D:\Test\Test\Test.html" but you will be getting something different due to routing.