您的位置:首页 > Web前端 > JavaScript

JavaScript读取文件路径

2015-12-30 17:42 621 查看
<!--获取当前文件全路径-->
<script language="javascript">

document.write(window.location.href);document.write("<br>");

document.write(window.location);document.write("<br>");

document.write(location.href);document.write("<br>");

document.write(parent.location.href);document.write("<br>");

document.write(top.location.href);document.write("<br>");

document.write(document.location.href);document.write("<br>");

document.write(document.URL);document.write("<br>");
document.write("<br>");document.write("<br>");

</script>

<!--//获取当前目录方法-->
<script type="text/javascript">

//方法一

var str = location.href;

var arr = str.split("/");

delete arr[arr.length-1];

var dir = arr.join("/");

//alert(dir);
document.write(dir);document.write("<br>");

//方法二

document.write(location.href.substring(0,location.href.lastIndexOf('/')));document.write("<br>");
document.write("<br>");document.write("<br>");
</script>

<!--//获取当前文件名-->
<script language=javascript>

var  filename=location.href;

filename=filename.substr(filename.lastIndexOf('/')+1);

//alert(filename);

document.write(filename);
</script>

<script>document.write(new Date());</script><显示日期

<script language="vbscript" runAt="Server">document.write(new%20Date());</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: