js火狐取本地绝对路径的方法

来源:互联网 发布:python调用shell命令 编辑:程序博客网 时间:2024/05/17 08:36

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

http://www.cnblogs.com/hcbin/archive/2010/06/20/1761149.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 pathtry {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时,会弹出一个警告窗口,点确定即可。