谁能帮我JavaScript改一下在Firefox里面使用?这个页面在IE运行正常,FF就不认,我知道原因但不懂JS!
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-image: url(images/index.jpg);
}
-->
</style>
<script language="javascript">
<!--
function getkey(){
asc = event.keyCode;
key = String.fromCharCode(asc);
if(key == "S"||key=='R'||key=='A'||key=='H'){
ret = confirm;
if(key=="S") url="sale11.html";
else if(key=="R") url="rent11.html";
else if(key=="H") url="index.html";
else if(key=="A") url="auction11.html";{
window.location = url;
}
}
}
document.onkeydown=getkey;
-->
</script>
</head>
<body>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-image: url(images/index.jpg);
}
-->
</style>
<script language="javascript">
<!--
function getkey(){
asc = event.keyCode;
key = String.fromCharCode(asc);
if(key == "S"||key=='R'||key=='A'||key=='H'){
ret = confirm;
if(key=="S") url="sale11.html";
else if(key=="R") url="rent11.html";
else if(key=="H") url="index.html";
else if(key=="A") url="auction11.html";{
window.location = url;
}
}
}
document.onkeydown=getkey;
-->
</script>
</head>
<body>
</body>
</html> 展开
2个回答
展开全部
你试试下下面的代码,如果不行,你再HI我好了:
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-image: url(images/index.jpg);
}
-->
</style>
</head>
<body>
</body>
<script language="javascript">
<!--
function getkey(ev){
var oEvent=ev||event;
asc = oEvent.keyCode;
key = String.fromCharCode(asc);
if(key == "S"||key=='R'||key=='A'||key=='H'){
ret = confirm;
if(key=="S") url="sale11.html";
else if(key=="R") url="rent11.html";
else if(key=="H") url="index.html";
else if(key=="A") url="auction11.html";{
window.location = url;
}
}
}
document.onkeydown=getkey;
-->
</script>
</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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-image: url(images/index.jpg);
}
-->
</style>
</head>
<body>
</body>
<script language="javascript">
<!--
function getkey(ev){
var oEvent=ev||event;
asc = oEvent.keyCode;
key = String.fromCharCode(asc);
if(key == "S"||key=='R'||key=='A'||key=='H'){
ret = confirm;
if(key=="S") url="sale11.html";
else if(key=="R") url="rent11.html";
else if(key=="H") url="index.html";
else if(key=="A") url="auction11.html";{
window.location = url;
}
}
}
document.onkeydown=getkey;
-->
</script>
</html>
追问
非常感谢你!!!!!!!!!!!!!!!!!
展开全部
e = e ? e : window.event;
evt = (evt) ? evt : ((window.event) ? window.event : "");
//兼容IE和Firefox获得keyBoardEvent对象
IE浏览器 e = window.event;如果是 FF e = e
evt = (evt) ? evt : ((window.event) ? window.event : "");
//兼容IE和Firefox获得keyBoardEvent对象
IE浏览器 e = window.event;如果是 FF e = e
更多追问追答
追问
谢谢,你说的这些代码要填写在哪个位置?
追答
event该对象,单独定义一个变量即可,
evt = (evt) ? evt : ((window.event) ? window.event : "");
asc = evt.keyCode;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询