用JavaScript封装下FileSystemObject,做下文件操作!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor
*/
var File = {
name:'',
path:'',
ext:'',
cfiles:[],
attributes:{
driver:'',
parentFolder:'',
shortName:'',
shortPath:'',
type:''
},
getInstance:function(){
var reObj = {};
this.path = arguments[0];
this.name = arguments[1];
Object.extend(reObj, this);
//初始化FSO对象
try{
this.fso = new ActiveXObject("Scripting.FileSystemObject");
if(!(fso.FolderExists(this.path))){
fso.CreateFolder(this.path);
};
}catch(e){
alert(e.message);
return;
};
//如果是文件夹,获得该文件夹下所有文件
if("" == this.name){
this.attributes.type = 'FOLDER';
var folder = fso.GetFolder(this.path);
this.cfiles = new Enumerator(folder.Files);
}else{
相关文档:
一、类型转换的方法和应该注意的问题:
1,转换为布尔型:
(1)用两次非运算(!):
!!5 ==> true
(2)用布尔型的构造函数:
new Boolean(5) == > true
值转换为布尔类型为false:
0,+0,-0,NaN,""(空字符串),undefined,null
除上面的值其他值在转换以后为true,需要特别提到的是:
"0",new Object(),funct ......
二、动态给表插入行:
function addRow(){
//动态插入一行
var oRow1=mediaMes.insertRow(mediaMes.rows.length);
//设置tr的id
oRow1.id="tr"+thisId;
//获得表总的行数
var aRows=mediaMes.rows;
//获得新添加行的列集合
var aCells=oRow1. ......
//把数据写入数据库
function
res(){
//获取输入值(myname和mymail是两个文本框的id)
var
uname = document.getElementById("myname"
).value;
var
umail = document.getElementById("mymail"
).value;
......
详解javascript类继承机制的原理
目前 javascript的实现继承方式并不是通过“extend”关键字来实现的,而是通过constructor function和prototype属性来实现继承。首先我们创建一个animal类
js 代码
var animal = function(){ //这就是constructor function 了&nbs ......
1.可以通过prototype属性,实现继承方法的方式,这种方式就是java语言中继承的变换形式。
// Create the constructor for a Person object
function Person( name ) {
this.name = name;
}
// Add a new method to the Person object
Person.prototype.getName = function() {
  ......