为window添加新成员

s

在webview里需要在pc上测试,所以会有这样的要求。

var mytempSave = {
    put : function(key,value){this[key] = value},
    get : function(key){
    	var a = this[key];
    	if(!a) a = "";
    	return this[key];
    	},
    contains : function(key){return this.Get(key) == null?false:true},
    remove : function(key){delete this[key]}
}

var andych008 = new Object();
andych008.isBackground = function (){
	console.log("andych008.isBackground()");
	return false;	
};
andych008.setMsgNum = function (num){
	console.log("andych008.setMsgNum:"+num);	
};
andych008.setNotice = function (noticeStr){
	console.log("andych008.setNotice:");
	console.log(noticeStr);

};
andych008.dangdang = function (){
	console.log("andych008.dangdang()");
};
andych008.tempGet = function (key){
	console.log("andych008.tempGet:"+key);
	return mytempSave.get(key);	
};
andych008.tempPut = function (key, value){
	console.log("andych008.tempPut:"+"_key="+key+"\t_value="+value);
	return mytempSave.put(key, value);	
};	

window.andych008 = andych008;



然后就可以直接通过window.andych008.dangdang()等访问这些方法


s




s

你可能感兴趣的:(为window添加新成员)