MPBrowser. js
Copy codeThe Code is as follows:
Var thisImgNo = 290;
Function ajaxConn (){
Var xmlhttp = false;
Try {xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP ");}
Catch (e) {try {xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");}
Catch (e) {try {xmlhttp = new XMLHttpRequest ();}
Catch (e) {alert (e); xmlhttp = false ;}}}
If (! Xmlhttp) return null;
This. connect = function (Url, Method, postContent ){
If (! Xmlhttp) return false;
Method = Method. toUpperCase ();
Try {
If (Method = "GET "){
Xmlhttp. open (Method, Url + '? '+ PostContent, true );
Xmlhttp. setRequestHeader ("Content-Type", "text/html; charset = GB2312 ");
SVars = null;
} Else {
Xmlhttp. open (Method, Url, true );
Xmlhttp. setRequestHeader ("Method", "POST" + Url + "HTTP/1.1 ");
Xmlhttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ");
}
Xmlhttp. onreadystatechange = function (){
If (xmlhttp. readyState = 4 ){
If (xmlhttp. status = 200 ){
ImgInfo = xmlhttp. ResponseText;
Var imgInfoArr = imgInfo. split ("| ");
Var tmpimg = new Image ();
Tmpimg. src = imgInfoArr [0];
ThisImgNo = imgInfoArr [1];
Var element = document. getElementById ("img ");
If (! Element. xpos) element. xpos = 0;
Element. style. width = (element. clientWidth + 130) + "px ";
SlideElement ("img", element. xpos-130 );
Element. innerHTML + = '<a href = "http://blog.mzoe.com/" target = "_ blank"> </a> ';
}
}
}
Xmlhttp. send (postContent );
} Catch (z) {return false ;}
Return true;
}
Return this;
}
Function loadImg (type ){
Var element = document. getElementById ("img ");
If (! Element. xpos) element. xpos = 0;
If (type = "pre "){
If (element. xpos = 0) return false;
SlideElement ("img", element. xpos + 130,0, 10 );
} Else {
If (element. xpos =-(element. clientWidth-260 )){
Var myConn = new ajaxConn ();
If (! MyConn) return false;
MyConn. connect ("Cmd. asp", "get", "d =" + thisImgNo );
} Else {
SlideElement ("img", element. xpos-130 );
}
}
}
Function slideElement (elementId, x, y, inc ){
Var element = document. getElementById (elementId );
If (element. sliding) clearTimeout (element. sliding );
If (! Element. xpos) element. xpos = 0;
If (! Element. ypos) element. ypos = 0;
If (element. xpos = x & element. ypos = y) return true;
If (element. xpos> x ){
Var dist = Math. ceil (element. xpos-x)/inc );
Element. xpos = element. xpos-dist;
}
If (element. xpos <x ){
Var dist = Math. ceil (x-element.xpos)/inc );
Element. xpos = element. xpos + dist;
}
If (element. ypos> y ){
Var dist = Math. ceil (element. ypos-y)/inc );
Element. ypos = element. ypos-dist;
}
If (element. ypos <y ){
Var dist = Math. ceil (y-element.ypos)/inc );
Element. ypos = element. ypos + dist;
}
Element. style. left = element. xpos + 'px ';
Element. style. top = element. ypos + 'px ';
Element. sliding = setTimeout ('slideelement ("'+ elementId +'", '+ x +', '+ y +', '+ inc +') ', 10 );
}
The main features of MPBrowser are no refreshing, easy to use, and simple code. Only a few kb of js code can be easily integrated with any background, in the end, the beauty is pretty nice (of course, it is quite convenient to change the style ).
Demo address: http://www.mzoe.com/demo/MPBrowser/
: Http://www.mzoe.com/downfile/MPBrowser_v1.rar
My favorite friend is D.