//获取当前文件全路径
<script language="javascript">alert(window.location.href); alert(window.location); alert(location.href); alert(parent.location.href); alert(top.location.href); alert(document.location.href); alert(document.URL);</script> //获取当前目录方法 <script type="text/javascript">//方法一 var str = location.href; var arr = str.split("/"); delete arr[arr.length-1]; var dir = arr.join("/"); alert(dir); //方法二 alert(location.href.substring(0,location.href.lastIndexOf('/')));</script> //获取当前文件名 <script language="javascript">var filename=location.href; filename=filename.substr(filename.lastIndexOf('/')+1); alert(filename);</script>