键盘事件如何兼容FireFOX
最常用的左右键翻页功能,在有DTD情况下求兼容FF的解决方法![html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
document.onkeydown=keypage
var prevpage="prevpage.htm"
var nextpage="nextpage.htm"
function keypage() {
if (event.keyCode==37) {location=prevpage}
if (event.keyCode==39) {location=nextpage}
}
</script>
</head>
<body>
(快捷键←)上一页 下一页(→快捷键)
</body>
</html>[/html]
[[i] 本帖最后由 shi2713 于 2008-8-28 10:33 编辑 [/i]] 没人帮解决一下吗? 顶! [html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
<!--
document.onkeydown = function( event_e ){
if( window.event )
event_e = window.event;
var int_keycode = event_e.charCode||event_e.keyCode;
if( int_keycode == '37' )
alert( 'left' );
if( int_keycode == '39' )
alert( 'right' );
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<div align="center">
<a href="javascript:document.location=prevpage">←</a>
<a href="javascript:document.location=nextpage">→</a>
</div>
</BODY>
</HTML>
[/html] 谢谢! [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
document.onkeydown=keypage
var prevpage="prevpage.htm"
var nextpage="nextpage.htm"
function keypage(e) {
var evt = e || window.event;
if (evt.keyCode==37) {location=prevpage}
if (evt.keyCode==39) {location=nextpage}
}
</script>
</head>
<body>
(快捷键←)上一页 下一页(→快捷键)
</body>
</html>[/code]
页:
[1]