首页 > web前端 > js教程 > 正文

Javascript技术技巧大全(五)_javascript技巧

WBOY
发布: 2016-05-16 19:20:30
原创
1010 人浏览过

//POST代替FORM 
<script> <BR>Function URLEncoding(vstrIn) <BR> strReturn = "" <BR> For i = 1 To Len(vstrIn) <BR> ThisChr = Mid(vStrIn,i,1) <BR> If Abs(Asc(ThisChr)) < &HFF Then <BR> strReturn = strReturn & ThisChr <BR> Else <BR> innerCode = Asc(ThisChr) <BR> If innerCode < 0 Then <BR> innerCode = innerCode + &H10000 <BR> End If <BR> Hight8 = (innerCode And &HFF00) &HFF <BR> Low8 = innerCode And &HFF <BR> strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8) <BR> End If <BR> Next <BR> URLEncoding = strReturn <BR>End Function <BR>Function bytes2BSTR(vIn) <BR> strReturn = "" <BR> For i = 1 To LenB(vIn) <BR> ThisCharCode = AscB(MidB(vIn,i,1)) <BR> If ThisCharCode < &H80 Then <BR> strReturn = strReturn & Chr(ThisCharCode) <BR> Else <BR> NextCharCode = AscB(MidB(vIn,i+1,1)) <BR> strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) <BR> i = i + 1 <BR> End If <BR> Next <BR> bytes2BSTR = strReturn <BR>End Function <BR>dim strA,oReq <BR>strA = URLEncoding("submit1=Submit&text1=中文") <BR>set oReq = CreateObject("MSXML2.XMLHTTP") <BR>oReq.open "POST","http://ServerName/VDir/TstResult.asp",false <BR>oReq.setRequestHeader "Content-Length",Len(strA) <BR>oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded" <BR>oReq.send strA <BR>msgbox bytes2BSTR(oReq.responseBody) <BR></script> 
//readyState是xmlhttp返回数据的进度,0=载入中,1=未初始化,2=已载入,3=运行中,4=完成 

//组件是否安装 
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> <BR> //用 JavaScript 写服务器端连接数据库的代码示例 <BR> var conn = new ActiveXObject("ADODB.Connection"); <BR> conn.Open("Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa; " <BR> +"Password=; Initial Catalog=pubs"); <BR> var rs = new ActiveXObject("ADODB.Recordset"); <BR> var sql="select * from authors"; <BR> rs.open(sql, conn); <BR> shtml = "<table width='100%' border=1>"; <BR> shtml +="<tr bgcolor='#f4f4f4'><td>au_id<td>au_lname<td>au_fname<td>phone<td>address<td> city<td>state<td>zip"; <BR> while(!rs.EOF) <BR> { <BR> shtml += "<tr><td>" + rs("au_id") + "<td>" + rs("au_lname") + "<td>" + rs("au_fname") + "<td>" + rs("phone") + "<td>" + rs("address") + "<td>" + rs("city") + "<td>" + rs("state") + "<td>" + rs("zip") + ""; <BR> rs.moveNext; <BR> } <BR> shtml += ""; <BR> document.write(shtml); <BR> rs.close(); <BR> rs = null; <BR> conn.close(); <BR> conn = null; <BR></script> 
//使用数据岛 


 

 
srno:
 
times:
 
 
   
" onclick="xmldate.recordset.moveNext()">   
>" onclick="xmldate.recordset.moveLast()">    
   

 
 
20041025-01null 
20041101-092004年10月1日2点22分0秒 
 
 
 
 
//获得参数 

 
search 
<script> <BR><!-- <BR>var a = location.search.substr(1); <BR>if(a.length>0) <BR>{ <BR> var re = /([^&]*?)=([^&]*)/g <BR> var s = a.match(re); <BR> for(var i= 0;i<s.length;i++) <BR> { <BR> alert(s[i]); <BR> alert(s[i].split("=")[1]); <BR> } <BR>} <BR>//--> <BR></script> 
 
//可编辑SELECT 

 
              
 
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板