JavaScript Technical Skills Encyclopedia (IV)

Source: Internet
Author: User
Tags array join return split window access
Tips//Refresh the unchanged text box<HTML>
<HEAD>
<meta name= "Save" content= "History" >
<STYLE>
. shistory {Behavior:url (#default #savehistory);}
</STYLE>
</HEAD>
<BODY>
<input class=shistory Type=text id=opersistinput>
</BODY>
</HTML>

//Access to the Clipboard (1) Drag and drop access
Event.dataTransfer.setData ("URL", OIMAGE.SRC);
Simageurl = Event.dataTransfer.getData ("URL")
(2) Ordinary visit
Window.clipboardData.setData ("Text", Osource.innertext);
Window.clipboardData.getData ("Text");

//Action Cookies

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, Dec 1999 23:59:59 GMT; ";
}

//settimeout Add Parameters

<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>


//Custom 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);
}; Download files

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 ("Download URL error!");
}
Window.confirm ("Download complete.");
}


//Verify that the connection is valid function GetXML (URL)
{
var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlHTTP. Open ("Get", URL, false);
Try
{
xmlHTTP. Send ();
}
catch (e) {}
Finally
{
var result = Xmlhttp.responsetext;
if (result)
{
if (XMLHTTP. STATUS==200)
{
return (true);
}
Else
{
return (false);
}
}
Else
{
return (false);
}
}
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.