function getPath(obj) {
if (obj) {
if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
obj.select();
return document.selection.createRange().text;
} else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}如果出现拒绝访问的情况,则在obj.select();下面加一个
doucument.getElementById("xx").focus();
xx为当前页面的任何一个dom对象
本文介绍了一种用于获取HTML元素中文件路径的跨浏览器兼容方法,特别针对Internet Explorer和Firefox进行了详细说明,并提供了一个实用的JavaScript函数实现。
2616

被折叠的 条评论
为什么被折叠?



