[JS] - 火狐得到文件的绝对路径(暂时的方法)

来源:http://hi.baidu.com/ypxmaomao/blog/item/83dee50a800ef91694ca6b51.html

第一步:打开“about:config”页面,查找“signed.applets.codebase_principal_support”属性,将其值设置为true。
设为TRUE
第二步:在javascript中采用以下代码进行获取:
复制内容到剪贴板
代码:

<script >
function getValueFF(id){
var ip = document.getElementById(id);
if (ip.files) {
//ffx3 - try to have access to full path
try {
netscape.security.PrivilegeManager.enablePrivilege(
'UniversalFileRead' )
}
catch (err) {
//need to set signed.applets.codebase_principal_support to true
}
};
return ip.value;
}

function show(){
alert(getValueFF(
"file1"))
}
</script>
<input id="file1" type="file" onChange="show()">

经过以上步骤,在Firefox3下获取file input的value时,会弹出一个警告窗口,点确定即可。

posted @ 2010-06-20 01:42  炎峰森林影  阅读(1946)  评论(0编辑  收藏  举报