用键盘方向键实现翻页

<script type="text/javascript">
document.onkeydown
= nextpage;
var prevpage="1.htm";
var nextpage="3.htm";
function nextpage(event)
{
event
= event ? event : (window.event ? window.event : null);
if (event.keyCode == 37) location = nextpage; //方向键→
if (event.keyCode == 39) location = prevpage; //方向键←
//方向键↑为38,方向键↓为40
}
</script>
posted @ 2011-03-12 14:19  顺德早茶  阅读(444)  评论(0编辑  收藏  举报