常用js代码大全3
三,高级应用(二)
//组件是否安装?
isComponentInstalled("{6B053A4B-A7EC-4D3D-4567-B8FF8A1A5739}", "componentID"))?
//检查网页是否存在?
function?CheckURL(URL)?
{?
??var?xmlhttp =?new?ActiveXObject("Microsoft.XMLHTTP");?
??xmlhttp.Open("GET",URL,?false);?
??try?
??{??
? ? xmlhttp.Send();??
? ??var?result = xmlhttp.status;?
??}?
??catch(e) {return(false); }?
??if(result==200)?
??{??
? ??return?true;?
??}?
??xmlhttp =?null;?
??return?false;?
}?
//连接数据库?
<script. language="javascript">?
??//用 JavaScript. 写服务器端连接数据库的代码示例?
??var?conn =?new?ActiveXObject("ADODB.Connection");?
??conn.Open("Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa; "
? ? +"Password=; Initial Catalog=pubs");?
??var?rs =?new?ActiveXObject("ADODB.Recordset");?
??var?sql="select * from authors";?
??rs.open(sql, conn);?
shtml =?"<table width='100%' border=1>";?
shtml +="<tr bgcolor='#f4f4f4'><td>au_id</td><td>au_lname</td><td>au_fname</td><td>phone</td><td>address</td><td> city</td><td>state</td><td>zip</td></tr>";?
??while(!rs.EOF)?
??{?
shtml +=?