JS control keyboard around key page effect code

Source: Internet
Author: User
Tags nets relative

Example 1

The code is as follows Copy Code

<script language=javascript>
Document.onkeydown = pageevent;
var prevpage= "http://www.111cn.net/";
var nextpage= "http://www.111cn.net/";
function Pageevent (evt) {
EVT = EVT | | window.event;
var key=evt.which| | Evt.keycode;
if (key = = Location = PrevPage
if (key = = Location = nextpage)
};
</SCRIPT>

Description: Press the keyboard ←→ direction key or PageUp pagedown key Direct page

The above is just a core code, let's look at the example application

The code is as follows Copy Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<meta name= "keywords" content= "webmaster, Web effects, JS special effects, JS script, script, advertising code, 111cn,111cn.net,sky,www.111cn.net, webmaster effects net"/>
<meta name= "description" content= "www.111cn.net, webmaster special effects nets, webmaster necessary JS special effects and advertising code. A large number of high-quality JS special effects, to provide high-quality advertising code to download, to do in webmaster effect nets "/>
<title> Special Effects support keyboard and mouse wheel page effect Webmaster Special effects Network welcome you. </title>
<style type= "Text/css" >
*{margin:0;padding:0;}
img{border:0;}
Li{list-style:none;}
A{text-decoration:none;}
A:hover{text-decoration:underline;}
Body{background: #262626; font-size:9px;font-family:verdana,geneva,sans-serif;}
.111cn_net{position:relative;width:960px;margin:0 Auto;}
. list{width:670px;}
. Entry{float:left;width:202px;position:relative;margin:10px;_display:inline;}
. entry a{display:block;text-decoration:none;border:1px #525252 solid;}
. entry a:hover{border:1px #999 solid;}
. Entry. Url{position:absolute;left:1px;bottom:1px;height:28px;width:200px;background: #000; text-align:center; Filter:alpha (opacity=80);-moz-opacity:0.8;opacity:0.8;}
. Entry. URL span{display:block;border:0;color: #fff; margin-top:6px;padding:2px;font-weight:bold;}
. _111cnnet{position:absolute;right:45px;top:10px;width:216px;padding:10px;background: #393939; border:1px #555 Solid;color: #fff;}
. _111cnnet li{margin-bottom:4px;}
. _111cnnet li.mt10{margin-bottom:10px;}
#url, #company, #description {color: #999;}
. _111cnnet a{color: #999;}
. _111cnnet a:hover{color: #fff;}
#content h1{color: #ccc; font-size:20px;text-align:center;padding:70px 0;}
#111cnnet {clear:both;color: #fff;}
#111cnnet a{color: #fff;}
#total {float:left;}
#_111cn_net {float:right;}
. F90{color: #f90;}
</style>
<script type= "Text/javascript" >
var siteList = {"Sites": [
{"URL": "Http://111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect One"},
{"URL": "Http://111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Second"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Third"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Fourth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Fifth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Sixth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Seventh"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect eighth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Nineth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect Tenth"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 11th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 12th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 13th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 14th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 15th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 16th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 17th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 18th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 19th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster effect 20th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 21st"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 22nd"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 23rd"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 24th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 25th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 26th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 27th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 28th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 29th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 30th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 31st"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 32nd"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 33rd"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 34th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 35th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 36th"},
{"URL": "Http://www.111cn.net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 37th"},
{"URL": "Http://111cnnet", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 38th"},
{"URL": "Http://www_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 39th"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 40th"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 41st"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 42nd"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 43rd"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 44th"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 45th"},
{"URL": "Http://_111cn_net", "Pic": "/img/111cn_net_201008112.jpg", "Name": "Webmaster Effect 46th"}
]
}
</script>
<a href= "http://www.111cn.net/" > Webmaster special effects Network &LT;/A&GT, Webmaster Essential high-quality Web page special effects and advertising code. 111cn.net, webmaster JS special effects. <!--Welcome to Webmaster Effects Network, our site collects a large number of high-quality JS special effects, providing a lot of advertising code download, URL: www.111cn.net,111cn@msn.com, with. NET to build Liang station-->
<body onload= "www_111cn_net ();" >
<!--Add the following code to <body> and </body>-->
<div class= "111cn_net" >
<div class= "List" >
<div id= "Content" ></div>
<div id= "111cnnet" >
<div id= "Total" ></div>
<div id= "_111cn_net" ></div>
</div>
</div>
<div class= "_111cnnet" >
<ul>
<li> website:</li>
<li id= "SiteURL" class= "mt10" ><a href= "Http://111cn.net" >http://www.111cn.net</a></li>
<li> company:</li>
<li id= "sitename" class= "mt10" > Webmaster special effects Net </li>
<li> Description:</li>
<li id= "description" > Focus on Web Effects and advertising code, to create the most handsome Web site special effects station! Welcome to collect this website, or recommend to your good friend! Feel good to come again next time! Webmaster Special Effects Network will not let you down! </li>
</ul>
</div>
</div>
<script type= "Text/javascript" >
<!--//
function $ (ID) {return document.getElementById (ID);} Define how to get IDs
function GotoPage (num) {//Jump page
Page = num;
Www_111cn_net ();
}//Welcome to Webmaster effects nets, our web site is www.111cn.net, very well remember, ZZ webmaster, JS is JS special effects, this site collects a large number of High-quality JS code, there are many advertising code download.
var PageSize = number of 9;//per page
var page = 1;//Current page number
function Www_111cn_net () {
var obj = eval (siteList);//Get JSON
var sites = obj.sites;
Get Total Paging
var Pages = Math.floor ((sites.length-1)/PageSize) + 1;
if (page < 1) page = 1;//If the current page number is less than 1
if (page > Pages) page = pages;//If the current page number is greater than the total
var Temp = "";
var Beginno = (Page-1) * PageSize + 1;//start number
var Endno = Page * pagesize;//End number
if (Endno > sites.length) endno = sites.length;
if (Endno = = 0) Beginno = 0;
if (!) ( Page <= pages) page = pages;
$ ("Total"). InnerHTML = "Total:<strong class= ' F90 ' >" + sites.length + "</strong> show:<strong class= ' F90 ' > "+ Beginno +"-"+ Endno + </strong>";
Paging
if (page > 1 && page!== 1) {Temp = "<a href= ' javascript:void (0) ' onclick= ' GotoPage (1) ' ><<Index< /a> <a href= ' javascript:void (0) ' onclick= ' GotoPage ("+ (Page-1) +") ' >Previous</a> '}else{temp = ' <&lt ; Index Previous "};
Perfect page-flipping list
var pagefrontsum = 3;//Display number before page
var pagebacksum = 3;//Display number after page
var Pagefront = pagefrontsum-(Page-1);
var pageback = pagebacksum-(pages-page);
if (Pagefront > 0 && pageback < 0) Pagebacksum + = pagefront;//before more, before remaining empty
if (Pageback > 0 && pagefront < 0) Pagefrontsum + = pageback;//less than before, the remaining vacancy to the front
var pagefrontbegin = page-pagefrontsum;
if (Pagefrontbegin < 1) Pagefrontbegin = 1;
var pagefrontend = Page + pagebacksum;
if (Pagefrontend > pages) pagefrontend = pages;
if (pagefrontbegin!= 1) Temp = ' <a href= ' javascript:void (0) "onclick=" GotoPage (' + (Page-10) + ') "title=" Top 10 pages ". .</a> ';
for (var i = Pagefrontbegin;i < Page;i + +) {
Temp + + "<a href= ' javascript:void (0) ' onclick= ' GotoPage (" + i + ") ' > ' + i +" </a> ";
}
Temp + = "<strong class= ' F90 ' >" + Page + "</strong>";
for (var i = Page + 1;i <= pagefrontend;i + +) {
Temp + + "<a href= ' javascript:void (0) ' onclick= ' GotoPage (" + i + ") ' > ' + i +" </a> ";
}
if (pagefrontend!= pages) Temp = "<a href= ' javascript:void (0) ' onclick= ' GotoPage (" + (Page +) + ") ' title= ' after 10 pages ' &G t;.. </a> ";
if (page!= Pages) {Temp + + <a href= ' javascript:void (0) ' onclick= ' GotoPage ("+ (page + 1) +"); ' >Next</a> <a href= ' javascript:void (0) ' onclick= ' GotoPage ("+ Pages +") ' >Last>></a> '}else{ Temp = "Next last>>"}
$ ("_111cn_net"). InnerHTML = Temp;
Output data
if (Endno = 0) {//If empty
$ ("content"). InnerHTML + = "Return
}
var html = "";
for (var i = Beginno-1;i < Endno;i + +) {
HTML + + "<div class= ' entry ' >";
html = "<a href= '" +sites[i]. url+ "' rel= ' bookmark ' title=" +sites[i]. Name+ ">";
html = "HTML + + <p class= ' url ' ><span> ' +sites[i]. Name+ "</span></p></a>";
HTML + "</div>";
}
$ ("content"). InnerHTML = html;
Clickshow ()//Call mouse click event
Keyboard key around the page
Document.onkeydown=function (e) {
var theevent = window.event | | E
var code = Theevent.keycode | | Theevent.which;
if (code==37) {
if (page > 1 && page!== 1) {
GotoPage (Page-1);
}
}
if (code==39) {
if (Page!= Pages) {
GotoPage (Page + 1);
}
}
}
Mouse wheel Page
function handle (Delta) {
if (Delta > 0) {
if (page > 1 && page!== 1) {
GotoPage (Page-1);
}
}
else{
if (Page!= Pages) {
GotoPage (Page + 1);
}
}
}
Function Wheel (event) {
var delta = 0;
if (!event)/* for IE. */
event = window.event;
if (Event.wheeldelta) {/* ie or opera. */
Delta = event.wheeldelta/120;
/** in Opera9, event handling differs from IE
*/
if (Window.opera)
Delta =-delta;
else if (event._111cnnet) {/** compatible with Mozilla. */
/** in Mozilla, sign of Delta are different than in IE.
* Also, Delta is multiple of 3.
*/
Delta =-EVENT._111CNNET/3;
}
/** Trigger if increment is not equal to 0
* Main function for the test wheel to roll up or down
*/
if (Delta)
Handle (delta);
}/
/** Initialization * *
if (Window.addeventlistener)
/** Mozilla's DOM-based wheel event **/
Window.addeventlistener ("Dommousescroll", wheel, false);
/** Ie/opera. */
Window.onmousewheel = Document.onmousewheel = wheel;
}
Get the link address and site name
function Showlink (source) {
var SiteURL = $ ("SiteURL");
var siteName = $ ("SiteName");
var description = $ ("description");
if (Source.getattribute ("rel") = = "Bookmark") {
var url = source.getattribute ("href");
var title = Source.getattribute ("title");
siteurl.innerhtml = "<a href= '" + URL + "' target= ' _blank ' >" + URL + "</a>";
sitename.innerhtml = title;
}
}
Mouse click events
function Clickshow () {
var links = $ ("content"). getElementsByTagName ("a");
for (var i=0; i<links.length; i++) {
var url = links[i].getattribute ("href");
var title = Links[i].getattribute ("title");
Links[i].onclick = function () {
Showlink (this);
return false;
}
}
}
-->
</script>
</body>

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.