//获取当前文件全路径
<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>
chrome 获取 input文件的路径
1. 加密的的blob
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
<input type="button" onclick="onchange1()" value="button" /> <script>
function onchange1(){
//alert(document.getElementById('files').value);
var f = window.URL.createObjectURL(document.getElementById('files').files[]);
alert(f);
}
</script>
获取项目路径
<!DOCTYPE html>
<html lang='en'>
<head>
<title>read</title>
<meta charset='utf-8' >
</head>
<body>
<form action="#" onsubmit="return savefile(this);">
<!-- 文本类型为txt 切换回文本框快捷键为Alt+z -->
<textarea name="txt" title=" Text edit area - Alt+Z " accesskey="z" rows="" cols=""></textarea>
<div>
<!-- 保存文本快捷键为Alt+s -->
<!-- 把鼠标移动到元素上面,就会显示title的内容 -->
<input title=" Save - Alt+S " class="key" accesskey="s" type="submit" value=" Save "> <label title=" Filename - Alt+A " for="filename">As</label>
<input name="filename" class="it" id="filename" accesskey="a" type="text" size="" value="D:\MazeSet\1">
<select name="ext" title=" Extension ">
<option value="iso-8859-1">.html</option>
<!-- selected 表示没人选择项 -->
<option selected="selected" value="utf-8">.txt</option>
</select>
<input title=" Remove null bytes - Alt+U " class="key" accesskey="u" onclick="this.form.elements.txt.value = unnull( this.form.elements.txt.value );" type="button" value=" Unnull ">
<input title=" Reset the form to its initial state - Alt+R " class="key" accesskey="r" type="reset" value=" Reset ">
</div>
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
<input type="button" onclick="onchange1()" value="button" />
<script>
function getContextPath(){
var pathName = document.location.pathname;
var index = pathName.substr().indexOf("/");
var result = pathName.substr(,index+);
alert(pathName);
return result;
}
getContextPath(); </script>
</body>
</html>