1. Whether the components are installed
// whether the component is installed iscomponentinstalled ("{6b053a4b-a7ec-4d3d-4567-b8ff8a1a5739}", "ComponentID"))
2. Check if the Web page exists
//Check if the Web page existsfunctionCheckurl (URL) {varXMLHTTP =NewActiveXObject ("Microsoft.XMLHTTP"); xmlHTTP. Open ("GET", URL,false); Try{xmlhttp. Send (); varresult =Xmlhttp.status; } Catch(e) {return(false); } if(result==200) { return true; } XMLHTTP=NULL; return false; }
3. Connect to the database
//connecting to a database<script language= "JavaScript" >//code example for writing server-side connection databases with JavaScript varconn =NewActiveXObject ("ADODB. Connection "); Conn. Open ("Provider=SQLOLEDB.1; Data Source=localhost; User Id=sa; "+" password=; Initial Catalog=pubs "); varrs =NewActiveXObject ("ADODB. Recordset "); varSql= "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+ = "<tr><td>" + RS ("au_id") + "</td><td>" + RS ("au_lname") + "</td><td>" + RS ("Au_fna Me ") +" </td><td> "+ RS (" phone ") +" </td><td> "+ RS (" address ") +" </td><td> "+ rs (" CIT Y ") +" </td><td> "+ RS (" state ") +" </td><td> "+ RS (" zip ") +" </td></tr> "; rs.movenext; } shtml+ = "</table>"; document.write (shtml); Rs.close (); RS=NULL; Conn.close (); Conn=NULL; </script>
4. Using the data island
//using the data islandSrno:<input type=text datasrc= #xmldate datafld=srno size= "><BR>"Times :<input type=text datasrc= #xmldate datafld=times size= "" "><BR> <input id=" First "Type=button value=" << first Record "onclick=" Xmldate.recordset.moveFirst () "> <input id=" prev "Type=button value=" < previous record "OnClick = "xmldate.recordset.movePrevious ()" > <input id= "Next" Type=button value= "next Record >" onclick= " Xmldate.recordset.moveNext () "> <input id=" Last "Type=button value=" final record >> "onclick=" Xmldate.recordset.moveLast () "> <input id=" Add "Type=button value=" adding a new record "onclick=" Xmldate.recordset.addNew () " > <xml id= "xmldate" > <infolist> <info ><srno>20041025-01</srno><times>null </times></info> <info ><srno>20041101-09</srno><times>2004 October 1 2:22 0 seconds </ times></info> </infolist> </XML> </body> 5. Get Parameters
// get parameters <body> <a href= " Javascript:location.href=location.href + '? a=1&b=2 ' ">search</a> <script language=" JavaScript "> <!--var a = location.search.substr (1 if (A.length>0 var re =/([^&]*?) \= ([^&]*)/g var s = A.match (re); for (var i= 0;i<s.length;i++< Span style= "color: #000000;" >) {alert (s); Alert (S.split ( "=") [1 // --> </script> < /body>
6. Operation Execl
//Operation Execl<script language= "JavaScript" >functionJstartexcel () {varXLS =NewActiveXObject ("Excel.Application" ); Xls.visible=true; varNewbook =xls. Workbooks.Add; NEWBOOK.WORKSHEETS.ADD; Newbook.worksheets (1). Activate; Xls. ActiveWorkBook.ActiveSheet.PageSetup.Orientation= 2; xls. ActiveWorkBook.ActiveSheet.PageSetup.PaperSize= 5; Newbook.worksheets (1). Columns ("A"). columnwidth=50; Newbook.worksheets (1). Columns ("A"). WrapText =true; Newbook.worksheets (1). Columns ("B"). columnwidth=50; Newbook.worksheets (1). Columns ("B"). WrapText =true; Newbook.worksheets (1). Range ("a1:b1000"). NumberFormat = "0"; Newbook.worksheets (1). Range ("a1:b1000"). HorizontalAlignment =-4131; Newbook.worksheets (1). Cells (a). interior.colorindex= "15"; Newbook.worksheets (1). Cells (value=) "First Column, first Cell"; Newbook.worksheets (1). Cells (2,1). value= "First Column, Second Cell"; Newbook.worksheets (1). Cells. value= "Second Column, First Cell"; Newbook.worksheets (1). Cells (2,2). value= "Second Column, Second Cell"; Newbook.worksheets (1). Name= "My First WorkSheet"; } </script>7. Custom Cue Bar
Custom Cue Bar
<a href= "#" title= "This is Tip" >tip</a> <script language= "JavaScript" >//*********** default settings are defined. *********************tpopwait=50;//stay twait seconds after the prompt is displayed. tpopshow=5000;//show tshow seconds after closing promptShowpopstep=20; popopacity=99; //*************** internal variable definition *****************spop=NULL; Curshow=NULL; Tfadeout=NULL; Tfadein=NULL; tfadewaiting=NULL; document.write ("<style type= ' text/css ' id= ' Defaultpopstyle ' >"); document.write (". Cpoptext {background-color: #F8F8F5; color: #000000; border:1px #000000 solid;font-color:font-size:12px; padding-right:4px; padding-left:4px; height:20px; padding-top:2px; padding-bottom:2px; Filter:alpha (opacity=0)} "); document.write ("</style>"); document.write ("<div id= ' dypoplayer ' style= ' position:absolute;z-index:1000; ' class= ' Cpoptext ' ></div>");functionShowpopuptext () {varo=event.srcelement; MouseX=Event.x; Mousey=Event.y;if(o.alt!=NULL&& o.alt!= "") {O.dypop=o.alt;o.}; if(o.title!=NULL&& o.title!= "") {o.dypop=o.title;o.title= ""}; if(o.dypop!=SPop) {SPop=O.dypop; cleartimeout (curshow); cleartimeout (tfadeout); cleartimeout (Tfadein); Cleartimeout (tFadeWaiting) ;if(spop==NULL|| spop== "") {dypoplayer.innerhtml=""; DypopLayer.style.filter= "Alpha ()"; dypopLayer.filters.Alpha.opacity=0; } Else { if(o.dyclass!=NULL) popstyle=O.dyclassElsePopstyle= "Cpoptext"; Curshow=settimeout ("Showit ()", tpopwait); } } } functionShowit () {dypoplayer.classname=Popstyle; dypoplayer.innerhtml=SPop; Popwidth=dypoplayer.clientwidth; Popheight=Dypoplayer.clientheight;if(mousex+12+popwidth>document.body.clientwidth) popleftadjust=-popwidth-24ElsePopleftadjust=0; if(mousey+12+popheight>document.body.clientheight) poptopadjust=-popheight-24ElsePoptopadjust=0; DypopLayer.style.left=mousex+12+document.body.scrollleft+popleftadjust; DypopLayer.style.top=mousey+12+document.body.scrolltop+poptopadjust; DypopLayer.style.filter= "Alpha (opacity=0)"; FadeOut ();} functionFadeOut () {if(dypoplayer.filters.alpha.opacity<popopacity) {dypopLayer.filters.Alpha.opacity+=showpopstep; Tfadeout=settimeout ("FadeOut ()", 1); } Else{dypopLayer.filters.Alpha.opacity=popopacity; tfadewaiting=settimeout ("FadeIn ()", tpopshow); } } functionfadeIn () {if(dypoplayer.filters.alpha.opacity>0) {dypopLayer.filters.Alpha.opacity-=1; Tfadein=settimeout ("FadeIn ()", 1); }} document.onmouseover=Showpopuptext;</script>
8. Determine the key value
varIE =navigator.appname== "Microsoft Internet Explorer"?true:false; functionKeyDown (e) {if(!IE) { varnkey=E.which; varIekey= ' is now the NS browser '; varrealkey=String.fromCharCode (E.which);} if(IE) {variekey=Event.keycode; varNkey= ' is now IE browser '; varrealkey=String.fromCharCode (Event.keycode); if(event.keycode==32) {realkey= ' \ ' space \ '} if(event.keycode==13) {realkey= ' \ ' enter \ '} if(event.keycode==27) {realkey= ' \ ' esc\ '} if(event.keycode==16) {realkey= ' \ ' shift\ '} if(EVENT.KEYCODE==17) {realkey= ' \ ' ctrl\ '} if(event.keycode==18) {realkey= ' \ ' alt\ '}} alert (' NS Browser key value: ' +nkey+ ' \ n ' + ' IE browser key: ' +iekey+ ' \ n ' + ' actual key is ' + 'Realkey); } Document.onkeydown=KeyDown;</script> //Javascript Document.9. Acquisition of InnerText
<script language= "JavaScript" > <!--varxmldoc =NewActiveXObject ("msxml2.domdocument.4.0"); varCurrnode; Xmldoc.async=false; Xmldoc.async=false; Xmldoc.loadxml ("<TABLENAME> Hello you three Dafa justice et al four </TABLENAME>"); Currnode=xmldoc.documentelement; vars =Currnode.xml; varr =/\< ([^\>\s]*?) [^\>]*?\> ([^\<]*?) \<\/\1\>/varb = S.replace (R, "$"); alert (b); // -</SCRIPT>JavaScript advanced Application (ii) (EXT)