機能性jsコード紹介
5151 ワード
1.
var msg=/[^/x00-/xff]/g.test(str)?" ":" "
2.screen
screen.availHeight(availWidth ) ( ), Microsoft; Windows 。
screen.height(width) ( )
screen.updateInterval
3.
document.body.clientWidth(clientHeight ) ( )
document.body.offsetWeight(offsetHeight ) ( )
document.body.scrollWidth(scrollHeight) ( )
document.body.scrollTop (scrollLeft ) ( )
window.screenTop(screenLeft) ( )
4.
<input type=button value= onclick="window.external.ImportExportFavorites(true,'http://localhost');">
<input type=button value= onclick="window.external.ImportExportFavorites(false,'http://localhost');">
<input type=button value= onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)">
<input type=button value= onclick="window.external.ShowBrowserUI('LanguageDialog', null)">
<input type=button value= onclick="window.external.AddFavorite('http://www.google.com/', 'google')">
<input type=button value= onclick="window.external.addChannel('http://www.google.com/')">
<input type=button value=PrivacySettings onclick="window.external.showBrowserUI('PrivacySettings',null)">
5.
function checkBrowser()
{
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.mac=(this.ver.indexOf('Mac') > -1) ?1:0;
this.ope=(navigator.userAgent.indexOf('Opera')>-1);
this.ie=(this.ie6 || this.ie5 || this.ie4)
this.ns=(this.ns4 || this.ns5)
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope)
this.nbw=(!this.bw)
return this;
}
6. cookie
function setcookie(key,value){
document.cookie=key+"="+escape(value)+"; ";
}
function getcookie(key){
var cookie=document.cookie.split("; ");
for(var i=0;i<cookie.length;i++){
return cookie.split("=")[0]==key?unescape(cookie.split("=")[1]);
}
}
function delcookie(key){
document.cookie =key+ "=aa"; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
7.js
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 !"+e);
}
window.confirm(" .");
}
8.
function checkUrl(url){
var xmlhttp=new ActiveObject("microsoft.xmlhttp");
xmlhttp.open("GET",url,false);
try{
xmlhttp.send();
}catch(e){
return false;
}
return xmlhttp.Status==200?true:false;
}
9.
function connectionDB(dataSource,DBName,UId,UPwd){
var connStr="Provider=SQLOLEDB.1;Data Source="+dataSource+";Initial Catalog="+DBName+";User ID="+UId+";Password="+UPwd;
var conn=new ActiveXObject("ADODB.Connection");
conn.open(connStr);
var rs=new ActiveXObject("ADODB.Recorddest");
var sql="select * name tbName"; // tbName (id,name)
re.open(sql,conn);//
var json='{"tbName":[';
while(!rs.EOF){ //
json+='{"id":"'+rs("id")+'"'+',"name":"'+rs("name")+'"},';
rs.moveNext;
}
json=json.RTrim(',')+"]}";
rs.close();//
rs=null;
conn.close();//
conn=null;
}
10 Math
LN10 (10 )
PI
SQR1_2 (1/2 )
abs(x) x
acos(x) x arc cosine
asin(x) x arc sin
atan(x) x arc tangent
ceil(x) x
exp(x) e x
floor(x) x
log(x) x
max(x,y) x,y
min(x,y) x,y
round(x) ( )
sin(x) x sin
cos(x) x consine
sqrt(x) x
tan(x) x tangent