<!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>
<title></title>
</head>
<script>
window.onload = function () { document.getElementById("bb").onblur = function (event) {
event ? event : window.event;
alert(event.button); } }</script>
<body>
<form>
<input id ="bb" type="text"/>
</form>
</body>
</html>
运行结果是打印出 undefined ,这是什么原因呢?有什么办法可以解决?谢谢
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<script>
window.onload = function () { document.getElementById("bb").onblur = function (event) {
event ? event : window.event;
alert(event.button); } }</script>
<body>
<form>
<input id ="bb" type="text"/>
</form>
</body>
</html>
运行结果是打印出 undefined ,这是什么原因呢?有什么办法可以解决?谢谢
event ? event : window.event;
alert(event.button); }
你这个方法中的event是哪来的??当然会是undefined
alert(e.button);
这种方法IE 下可以用 FF 和谷歌浏览器不行!这什么情况?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<!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>
<title></title>
</head>
<script>
window.onload = function () { document.getElementById("bb").onblur = function (e) {
var a=e||window.event;
alert(a.button); } }</script>
<body>
<form>
<input id ="bb" type="text"/>
</form>
</body>
</html>
只有ie可以 貌似
event=event ? event : window.event;
alert(event.button);
或者:
event=event||window.event其次,测试方式也是有问题
document.getElementById("myauto").onmousedown = function (event) {
event=event||window.event;
alert(event.button);
}再然后:event.button在不同的浏览器中,值是不一样的