script page.? DON'T SEE CODE JUST TRY TO UNDERSTANT THIS PROBLEM
please try to understand my problem. I am asp.net developer and trying to browse folder at client side so I got the javascript code in which I used activeXobject("Scripting.FIleSystemObject") .
if i run that code with notpad then it is executing fine. But when I created a .htm file in as.net ant putting that same code in .htm file then it is not executint and on debugging it is showing Undefined.
I want to get rid of this fuky problem. please ans me if you have sum idea abt it.
here is my code if want to expriment..........Dont try to understant this code if u r not getting just copy it and open with notepad.html , run it and see it.
<head>
<script language="JavaScript">
<!--
var currentFolder="";
function GetDriveList(){
var fso, obj, n, e, item, arr=[];
try
{
fso = new ActiveXObject("Scripting.FIleSystemObject");
}
catch(er)
{
alert('Could not load Drives. The ActiveX control could not be started.');
cancelFolder();
}
e = new Enumerator(fso.Drives);
for(;!e.atEnd();e.moveNext()){
item = e.item();
obj = {letter:"",description:""};
obj.letter = item.DriveLetter;
if (item.DriveType == 3) obj.description = item.ShareName;
else if (item.IsReady) obj.description = item.VolumeName;
else obj.description = "[Drive not ready]";
arr[arr.length]=obj;
}
return(arr);
}
function GetSubFolderList(fld){
var e, arr=[];
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(fld.toString());
var e = new Enumerator(f.SubFolders);
for(;!e.atEnd();e.moveNext()){
arr[arr.length]=e.item().Name;
}
return(arr);
}
function loadDrives(){
var drives=GetDriveList(),list="";
for(var i=0;i<drives.length;i++){
list+="<div onclick=\"loadList('"+drives.letter+':\\\')" class="folders" onmouseover="highlight(this)" onmouseout="unhighlight(this)">'+drives.letter+':\ - '+ drives.description+'</div>';
}
document.getElementById("path").innerHTML='<a href="" onclick="loadDrives();return false" title="My Computer">My Computer</a>\';
document.getElementById("list").innerHTML=list;
currentFolder="";
}
function loadList(fld)
{
var path="",list="",paths=fld.split("\");
var divPath=document.getElementById("path");
var divList=document.getElementById("list");
for(var i=0;i<paths.length-1;i++){
if(i==paths.length-2){
path+=paths+' \';
}else{
path+="<a href=\"\" onclick=\"loadList('";
for(var j=0;j<i+1;j++){
path+=paths[j]+"\\";
}
path+='\');return false">'+paths+'</a> \ ';
}
}
divPath.innerHTML='<a href="" onclick="loadDrives();return false">My Computer</a> \ '+path;
divPath.title="My Computer\"+paths.toString().replace(/,/g,"\");
currentFolder=paths.toString().replace(/,/g,"\");
var subfolders=GetSubFolderList(fld);
for(var j=0;j<subfolders.length;j++){
list+="<div onclick=\"loadList('"+(fld+subfolders[j]).replace(/\/g,"\\")+'\\\')" onmouseover="highlight(this)" onmouseout="unhighlight(this)" title="'+subfolders[j]+'" class="folders">'+subfolders[j]+"</div>";
}
divList.innerHTML=list;
resizeList();
divPath.scrollIntoView();
}
function selectFolder(){
window.returnValue=currentFolder;
window.close();
}
function cancelFolder(){
window.returnValue="";
window.close();
}
-->
</script>
<style>
#header{
background-color: #CCCCCC;
border-bottom: solid 1px black;
}
#path{
position:relative;
font-size: 8pt;
font-family: Arial;
font-weight: bold;
padding: 2px;
}
#list{
font-size: 10pt;
font-family: Arial;
overflow:auto;
height: 219px;
}
.folders{
padding: 1px;
border-top: solid 1px white;
border-left: solid 1px white;
border-right: solid 1px white;
border-bottom: solid 1px black;
cursor: hand;
pointer: hand;
background-color: white;
}
.folderButton{
padding: 0px;
border-style: outset;
border-width: 2px;
border-color:red;
cursor: hand;
pointer: hand;
background-color: #
yeah its ok , but how it could be possible that its running with notepad locally but not in asp.net's .htm file
please try to understand my problem. I am asp.net developer and trying to browse folder at client side so I got the javascript code in which I used activeXobject("Scripting.FIleSystemObject") .
if i run that code with notpad then it is executing fine. But when I created a .htm file in as.net ant putting that same code in .htm file then it is not executint and on debugging it is showing Undefined.
I want to get rid of this fuky problem. please ans me if you have sum idea abt it.
here is my code if want to expriment..........Dont try to understant this code if u r not getting just copy it and open with notepad.html , run it and see it.
<head>
<script language="JavaScript">
<!--
var currentFolder="";
function GetDriveList(){
var fso, obj, n, e, item, arr=[];
try
{
fso = new ActiveXObject("Scripting.FIleSystemObject");
}
catch(er)
{
alert('Could not load Drives. The ActiveX control could not be started.');
cancelFolder();
}
e = new Enumerator(fso.Drives);
for(;!e.atEnd();e.moveNext()){
item = e.item();
obj = {letter:"",description:""};
obj.letter = item.DriveLetter;
if (item.DriveType == 3) obj.description = item.ShareName;
else if (item.IsReady) obj.description = item.VolumeName;
else obj.description = "[Drive not ready]";
arr[arr.length]=obj;
}
return(arr);
}
function GetSubFolderList(fld){
var e, arr=[];
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(fld.toString());
var e = new Enumerator(f.SubFolders);
for(;!e.atEnd();e.moveNext()){
arr[arr.length]=e.item().Name;
}
return(arr);
}
function loadDrives(){
var drives=GetDriveList(),list="";
for(var i=0;i<drives.length;i++){
list+="<div onclick=\"loadList('"+drives.letter+':\\\')" class="folders" onmouseover="highlight(this)" onmouseout="unhighlight(this)">'+drives.letter+':\ - '+ drives.description+'</div>';
}
document.getElementById("path").innerHTML='<a href="" onclick="loadDrives();return false" title="My Computer">My Computer</a>\';
document.getElementById("list").innerHTML=list;
currentFolder="";
}
function loadList(fld)
{
var path="",list="",paths=fld.split("\");
var divPath=document.getElementById("path");
var divList=document.getElementById("list");
for(var i=0;i<paths.length-1;i++){
if(i==paths.length-2){
path+=paths+' \';
}else{
path+="<a href=\"\" onclick=\"loadList('";
for(var j=0;j<i+1;j++){
path+=paths[j]+"\\";
}
path+='\');return false">'+paths+'</a> \ ';
}
}
divPath.innerHTML='<a href="" onclick="loadDrives();return false">My Computer</a> \ '+path;
divPath.title="My Computer\"+paths.toString().replace(/,/g,"\");
currentFolder=paths.toString().replace(/,/g,"\");
var subfolders=GetSubFolderList(fld);
for(var j=0;j<subfolders.length;j++){
list+="<div onclick=\"loadList('"+(fld+subfolders[j]).replace(/\/g,"\\")+'\\\')" onmouseover="highlight(this)" onmouseout="unhighlight(this)" title="'+subfolders[j]+'" class="folders">'+subfolders[j]+"</div>";
}
divList.innerHTML=list;
resizeList();
divPath.scrollIntoView();
}
function selectFolder(){
window.returnValue=currentFolder;
window.close();
}
function cancelFolder(){
window.returnValue="";
window.close();
}
-->
</script>
<style>
#header{
background-color: #CCCCCC;
border-bottom: solid 1px black;
}
#path{
position:relative;
font-size: 8pt;
font-family: Arial;
font-weight: bold;
padding: 2px;
}
#list{
font-size: 10pt;
font-family: Arial;
overflow:auto;
height: 219px;
}
.folders{
padding: 1px;
border-top: solid 1px white;
border-left: solid 1px white;
border-right: solid 1px white;
border-bottom: solid 1px black;
cursor: hand;
pointer: hand;
background-color: white;
}
.folderButton{
padding: 0px;
border-style: outset;
border-width: 2px;
border-color:red;
cursor: hand;
pointer: hand;
background-color: #
yeah its ok , but how it could be possible that its running with notepad locally but not in asp.net's .htm file