1- < html >
2- < head >
3-
4- </ head >
5- < body >
6- < script >
7- /* AjaxHandler interface. */
1+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+ < html xmlns ="http://www.w3.org/1999/xhtml "> < head > < meta http-equiv ="Content-Type " content ="text/html; charset=UTF-8 ">
3+ < style type ="text/css ">
4+ body { background-color : # 000 ; font-family : "Courier New" , "Courier" ; font-size : 12px ; color : # 999999 ;}
5+ div {font-family : "Courier New" , "Courier" ; font-size : 24px ; color : # FFF ; text-decoration : none}
6+ div .main {margin-top : 120px ; text-align : center;}
7+ .showCodes {
8+ font-size : 25px ;
9+ width : 640px ;
10+ margin : 0px auto;
11+ color : # 00FF00 ;
12+ }
13+ </ style >
14+ </ head >
15+ < body style ="visibility:visible; ">
16+ < div class ="main ">
17+ < a style ="border:solid 0px #FFF " title ="点击进入技术分享页 " href ="http://hahaya.github.com/blog "> < img style ="border:none; " src ="images/unix.jpg "> </ a >
18+ < br >
19+ < br >
20+ </ div >
21+ < div id ="codes_1 " class ="showCodes " > > > </ div >
22+ < div id ="codes_2 " class ="showCodes " style ="display: none; "> > > </ div >
23+ < div id ="codes_3 " class ="showCodes " style ="display: none; "> > > </ div >
24+ < div id ="codes_4 " class ="showCodes " style ="display: none; "> > > </ div >
825
9- // var AjaxHandler = new Interface('AjaxHandler', ['request', 'createXhrObject']);
1026
11- /* SimpleHandler class. */
27+ < script language ="javascript ">
28+ window . a = function ( ) { document . body . style . visibility = "visible" } ; function b ( i ) { return window . document . getElementById ( i ) } ; var c = "cd hahaya.github.com" ; var d = c . length ; var e = 0 ; var f = 0 ; var g ; function h ( ) { if ( e == d ) { if ( 0 == f ) { b ( "codes_2" ) . style . display = "block" ; c = "Login:hahaya" ; e = 0 ; f = 1 ; d = c . length } else if ( 1 == f ) { b ( "codes_3" ) . style . display = "block" ; c = "Password:********" ; e = 0 ; f = 2 ; d = c . length } else if ( 2 == f ) { b ( "codes_4" ) . style . display = "block" ; c = "Success,Welcome!" ; e = 0 ; f = 3 ; d = c . length } else { clearInterval ( g ) ; document . location = "http://hahaya.github.com/blog" } } else { if ( 0 == f ) { b ( "codes_1" ) . innerHTML += c . charAt ( e ) } else if ( 1 == f ) { b ( "codes_2" ) . innerHTML += c . charAt ( e ) } else if ( 2 == f ) { b ( "codes_3" ) . innerHTML += c . charAt ( e ) } else if ( 3 == f ) { b ( "codes_4" ) . innerHTML += c . charAt ( e ) } ; e ++ } } ; g = setInterval ( function ( ) { h ( ) } , 45 ) ;
29+ </ script >
1230
13- var SimpleHandler = function ( ) { } ; // implements AjaxHandler
14- SimpleHandler . prototype = {
15- request : function ( method , url , callback , postVars ) {
16- var xhr = this . createXhrObject ( ) ;
17- xhr . onreadystatechange = function ( ) {
18- if ( xhr . readyState !== 4 ) return ;
19- ( xhr . status === 200 ) ?
20- callback . success ( xhr . responseText , xhr . responseXML ) :
21- callback . failure ( xhr . status ) ;
22- } ;
23- xhr . open ( method , url , true ) ;
24- if ( method !== 'POST' ) postVars = null ;
25- xhr . send ( postVars ) ;
26- } ,
27- createXhrObject : function ( ) { // Factory method.
28- var methods = [
29- function ( ) { return new XMLHttpRequest ( ) ; } ,
30- function ( ) { return new ActiveXObject ( 'Msxml2.XMLHTTP' ) ; } ,
31- function ( ) { return new ActiveXObject ( 'Microsoft.XMLHTTP' ) ; }
32- ] ;
33-
34- for ( var i = 0 , len = methods . length ; i < len ; i ++ ) {
35- try {
36- methods [ i ] ( ) ;
37- }
38- catch ( e ) {
39- continue ;
40- }
41- // If we reach this point, method[i] worked.
42- this . createXhrObject = methods [ i ] ; // Memoize the method. 记住该方法
43- return methods [ i ] ( ) ;
44- }
45-
46- // If we reach this point, none of the methods worked.
47- throw new Error ( 'SimpleHandler: Could not create an XHR object.' ) ;
48- }
49- } ;
5031
51- /* Usage. */
52-
53- var myHandler = new SimpleHandler ( ) ;
54- var callback = {
55- success : function ( responseText ) { alert ( 'Success: ' + responseText ) ; } ,
56- failure : function ( statusCode ) { alert ( 'Failure: ' + statusCode ) ; }
57- } ;
58- myHandler . request ( 'GET' , 'script.php' , callback ) ;
59-
60- </ script >
61- </ body >
62- </ html >
32+ </ body >
33+ </ html >
0 commit comments