jsp页面内选择文件夹并获得路径?
不是“文件”是“文件夹”,我有一段代码,就是提示错误:“无法设置属性‘value’的值:对象为null或未定义”,帮忙给解决一下,奖励50分<%@pagepageEnco...
不是“文件”是“文件夹”,我有一段代码,就是提示错误:“无法设置属性‘value’的值:对象为null或未定义”,帮忙给解决一下,奖励50分
<%@ page pageEncoding="utf-8"%>
<html>
<head>
<title>Filefolder</title>
<script language="javascript">
function browseFolder(path) {
/**//***
path 要显示值的对象id
****/
try {
var Message ="\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息
var Shell = new ActiveXObject("Shell.Application");
var Folder = Shell.BrowseForFolder(0, Message,64, 17); //起始目录为:我的电脑
//var Folder = Shell.BrowseForFolder(0,Message,0); //起始目录为:桌面
if (Folder != null) {
Folder = Folder.items(); // 返回 FolderItems 对象
Folder = Folder.item(); // 返回 Folderitem 对象
Folder = Folder.Path; // 返回路径
if (Folder.charAt(Folder.length - 1) != "\\") {
Folder = Folder + "\\";
}
document.getElementById(path).value =Folder;
return Folder;
}
}
catch (e) {
alert(e.message);
}}
</script>
</head>
<body><table><tr>
<td>Select Data Source:</td>
<td><input name="path" type=text ></td>
<td><input type=button value="Select" onclick="browseFolder(path)"></td>
</tr></table></body>
</html> 展开
<%@ page pageEncoding="utf-8"%>
<html>
<head>
<title>Filefolder</title>
<script language="javascript">
function browseFolder(path) {
/**//***
path 要显示值的对象id
****/
try {
var Message ="\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息
var Shell = new ActiveXObject("Shell.Application");
var Folder = Shell.BrowseForFolder(0, Message,64, 17); //起始目录为:我的电脑
//var Folder = Shell.BrowseForFolder(0,Message,0); //起始目录为:桌面
if (Folder != null) {
Folder = Folder.items(); // 返回 FolderItems 对象
Folder = Folder.item(); // 返回 Folderitem 对象
Folder = Folder.Path; // 返回路径
if (Folder.charAt(Folder.length - 1) != "\\") {
Folder = Folder + "\\";
}
document.getElementById(path).value =Folder;
return Folder;
}
}
catch (e) {
alert(e.message);
}}
</script>
</head>
<body><table><tr>
<td>Select Data Source:</td>
<td><input name="path" type=text ></td>
<td><input type=button value="Select" onclick="browseFolder(path)"></td>
</tr></table></body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询