如何使用javascript获取实际的windows路径
我正在尝试使用javascript查找工作目录的实际路径。我读了这篇文章如何使用javascript获取实际的windows路径,javascript,Javascript,我正在尝试使用javascript查找工作目录的实际路径。我读了这篇文章 警报(location.pathname);///tmp/test.html 警报(location.hostname);//本地服务器 警报(location.search);/?布拉赫=2 警报(document.URL);//http://localhost/tmp/test.html?blah=2#foobar 警报(location.href);//http://localhost/tmp/test.html
警报(location.pathname);///tmp/test.html
警报(location.hostname);//本地服务器
警报(location.search);/?布拉赫=2
警报(document.URL);//http://localhost/tmp/test.html?blah=2#foobar
警报(location.href);//http://localhost/tmp/test.html?blah=2#foobar
警报(位置.协议);//http:
警报(location.host);//本地服务器
警报(位置.原点);//http://localhost
警报(location.hash);//#福巴
但是没有一个是我一直在寻找的,因为我想找到路径,例如“C:/xampp/htdocs/myCurrentDirectory”。那么如何做到这一点
提前感谢……:) 你不能
URL和文件路径之间的任何连接都完全由HTTP服务器内部处理(可能根本不存在)。该关系的任何内容都不会向客户端公开,因此客户端代码无法了解它。您不能
URL和文件路径之间的任何连接都完全由HTTP服务器内部处理(可能根本不存在)。这种关系的任何内容都不会向客户机公开,因此客户机端代码对它一无所知
<script>
alert(location.pathname); // /tmp/test.html
alert(location.hostname); // localhost
alert(location.search); // ?blah=2
alert(document.URL); // http://localhost/tmp/test.html?blah=2#foobar
alert(location.href); // http://localhost/tmp/test.html?blah=2#foobar
alert(location.protocol); // http:
alert(location.host); // localhost
alert(location.origin); // http://localhost
alert(location.hash); // #foobar
</script>