为什么在ie中可以,在火狐里面不行!跳不出弹出框啊!
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><basehref="http:...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="http://localhost:80/js2/">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function body_onclick(){
alert("鼠标单击的坐标 是\r\nx:"+event.x+",y:"+event.y);
}
</script>
</head>
<body style="overflow:auto;padding:0px;margin:0px" onclick="body_onclick();">
This is my JSP pe. <br>
</body>
</html> 展开
<html>
<head>
<base href="http://localhost:80/js2/">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function body_onclick(){
alert("鼠标单击的坐标 是\r\nx:"+event.x+",y:"+event.y);
}
</script>
</head>
<body style="overflow:auto;padding:0px;margin:0px" onclick="body_onclick();">
This is my JSP pe. <br>
</body>
</html> 展开
2个回答
展开全部
您好!很高兴为您答疑。
您代码的问题是关于event在IE和火狐下的差异造成的。要想同时兼容火狐浏览器,您需要使用兼顾2种浏览器的写法(示例代码):
obj = obj||window.event;
var x = obj.x || obj.pageX;
var y = obj.y || obj.pageY;
其中obj为您传入事件的主对象,相当于this。
如果对我们的回答存在任何疑问,欢迎继续问询。
您代码的问题是关于event在IE和火狐下的差异造成的。要想同时兼容火狐浏览器,您需要使用兼顾2种浏览器的写法(示例代码):
obj = obj||window.event;
var x = obj.x || obj.pageX;
var y = obj.y || obj.pageY;
其中obj为您传入事件的主对象,相当于this。
如果对我们的回答存在任何疑问,欢迎继续问询。
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="http://localhost:80/js2/">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function body_onclick(e){
e = e||window.event;
var x = e.x || e.pageX, y = e.y || e.pageY;
alert("鼠标单击的坐标 是\r\nx:"+ x +",y:"+ y);
}
</script>
</head>
<body style="overflow:auto;padding:0px;margin:0px" onclick="body_onclick(event);">
This is my JSP pe. <br>
</body>
</html>
<html>
<head>
<base href="http://localhost:80/js2/">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function body_onclick(e){
e = e||window.event;
var x = e.x || e.pageX, y = e.y || e.pageY;
alert("鼠标单击的坐标 是\r\nx:"+ x +",y:"+ y);
}
</script>
</head>
<body style="overflow:auto;padding:0px;margin:0px" onclick="body_onclick(event);">
This is my JSP pe. <br>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询