Heim >Web-Frontend >js-Tutorial >Javascript技术技巧大全(五)_javascript技巧

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

WBOY
WBOYOriginal
2016-05-16 19:20:301033Durchsuche

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

 
              
 
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn