我正在尝试使用JavaScript获取当前的工作目录路径
当我从ubuntu执行时:$ root @ ubuntu:/ var / test / geek #firefox /var/www/application/test.html 我在警报框中输入/ var / www / application而不是在我的警告框中输入/ var / test / geek
使用了javascript代码:
var path=window.location.pathname
alert(path);
上面的代码给出了test.html的路径
编辑:是否可以使用perl脚本? Perl的CGI?
知道javascript无法实现之后,尝试使用perl脚本。
my $pwd=cwd();
并从html运行perl脚本:
当我从ubuntu执行时:$ root @ ubuntu:/ var / test / geek #firefox /var/www/application/test.html
我仍然在页面中使用/ var / www / application而不是/ var / test / geek。 从perl可以吗?
答案 0 :(得分:0)
我建议不要依赖于此。你得到的pathname
可能不是真正的路径。大多数情况下,开发人员使用路由来隐藏实际路径。
实际目录结构可能类似于“D:\ Test \ Test \ Test.html”,但由于路由,您将获得不同的内容。