Website true page JS code how to write?

Source: Internet
Author: User

True page of the word to the program apes, not a strange vocabulary, but if you are the first to learn true pagination, perhaps it will take a little time to study, the following is to the turntable network (like can see, can also enter the engine mode) of the True page JS part of the code, the HTML part of the I will not write, A little bit of code can be used, you can also be flexible according to needs, do not lazy oh, nonsense not to say, directly on the code:

Functions Get_param (param) {//This function is used to get the parameters of the URL

var query = location.search.substring (1). Split (' & ');
for (Var i=0;i<query.length;i++) {
var kv = query[i].split (' = ');
if (kv[0] = = param) {
return kv[1];
}
}
return null;
}

$ ("#page_down"). Unbind (). bind (' click ', function () {//PAGE Down

Temp=get_param ("CurrentPage");
if (Temp==null | | IsNaN (TEMP)) {//non-numeric or no page number
topage=1;
}
else{
Topage=parseint (temp) +1;
}
ifnull=$ ("#ifnull"). attr ("value");
if (ifnull.length<3) {
topage=1;
}
Url= "${pagecontext.request.contextpath}/funnypic.do?currentpage=" +topage;
Window.location.replace (URL);
});

$ ("#home"). Unbind (). bind (' click ', function () {//Return to home page
Url= "${pagecontext.request.contextpath}/funnypic.do?currentpage=1";
Window.location.replace (URL);
});

$ ("#page_up"). Unbind (). bind (' click ', function () {//PAGE UP
Temp=get_param ("CurrentPage");
if (Temp==null | | IsNaN (TEMP)) {//non-numeric or no page number
topage=1;
}
else{
Topage=parseint (temp)-1;
}
if (topage<1) {
ShowMessage ("Pro ~ First page, really do not know where to go");
Return
}
ifnull=$ ("#ifnull"). attr ("value");
if (ifnull.length<3) {
topage=1;
}
Url= "${pagecontext.request.contextpath}/index.do?currentpage=" +topage;
Window.location.replace (URL);
});

$ (". Turnpage"). Unbind (). bind (' click ', function () {//Page Turn section code
Topage=parseint ($ (this). Text () + "");
ifnull=$ ("#ifnull"). attr ("value");
if (ifnull.length<3) {
topage=1;
}
Url= "${pagecontext.request.contextpath}/funnypic.do?currentpage=" +topage;
Window.location.replace (URL);
});

Website true page JS code how to write?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.