代码如下:
脚本文件
<script type="text/javascript">
function openWindow(){
var savePath;
var objSrc=new ActiveXObject("Shell.Application").BrowseForFolder(0,'请选择文件目录:',0,'');
if(objSrc!=null){
savePath=objSrc.Items().Path;
document.all.savePath.value=savePath; }
}
</script>
html文件
<input type="text" name="savePath"/>
<input type="button" value="浏览..." onclick="openWindow()">
现在文本框中的值是undefined,不知道怎么回事,多谢了
脚本文件
<script type="text/javascript">
function openWindow(){
var savePath;
var objSrc=new ActiveXObject("Shell.Application").BrowseForFolder(0,'请选择文件目录:',0,'');
if(objSrc!=null){
savePath=objSrc.Items().Path;
document.all.savePath.value=savePath; }
}
</script>
html文件
<input type="text" name="savePath"/>
<input type="button" value="浏览..." onclick="openWindow()">
现在文本框中的值是undefined,不知道怎么回事,多谢了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<input type="text" id="filepatn" name="filepath" /><input type="button" value="浏览" onclick="document.getElementById('filectl').click()">
<input type="file" id="filectl" style="display:none;" onchange="document.getElementById('filepath').value=this.value;">
</body>
</html>