Tag: xml预览模式: 普通 | 列表

JavaScript操作xml,cookie

//操作COOKIE

function SetCookie(sName, sValue)
{
document.cookie = sName + "=" + escape(sValue) + "; ";
}
function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
  
  var aCrumb = aCookie[i].split("=");
  if (sName == aCrumb[0])
  return unescape(aCrumb[1]);
}

}
function DelCookie(sName)
{
document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

//setTimeout增加参数

<script>
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function'){
  var argu = Array.prototype.slice.call(arguments,2);
  var f = (function(){ fRef.apply(null, argu); });
  return _st(f, mDelay);
}
return _st(fRef,mDelay);
}
function test(x){
alert(x);
}
window.setTimeout(test,1000,'fason');
</script>


//自定义的apply,call

Function.prototype.apply = function (obj, argu) {
if (obj) obj.constructor.prototype._caller = this;
var argus = new Array();
for (var i=0;i<argu.length;i++)
   argus[i] = "argu[" + i + "]";
var r;
eval("r = " + (obj ? ("obj._caller(" + argus.join(",") + ");") : ("this(" + argus.join(",") + ");")));
return r;
};
Function.prototype.call = function (obj) {
var argu = new Array();
for (var i=1;i<arguments.length;i++)
   argu[i-1] = arguments[i];
return this.apply(obj, argu);
};       


//下载文件

function DownURL(strRemoteURL,strLocalURL)
{
try
{
  var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
   xmlHTTP.open("Get",strRemoteURL,false);
   xmlHTTP.send();
  var adodbStream=new ActiveXObject("ADODB.Stream");
   adodbStream.Type=1;//1=adTypeBinary
   adodbStream.Open();
   adodbStream.write(xmlHTTP.responseBody);
   adodbStream.SaveToFile(strLocalURL,2);
   adodbStream.Close();
   adodbStream=null;
   xmlHTTP=null;
  
}
catch(e)
{
   window.confirm("下载URL出错!");
}
//window.confirm("下载完成.");
}

查看更多...

Tags: javascript xml cookie

分类:软件技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 668