用的IE7:<!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>
function onMouse(){
alert("onmousedown");
}
function onClic(){
alert("onClick");
}
</script>
</head>
<body>
<input id="btn" type="button" value="点击" onmousedown="onMouse()" onclick="onClic()" />
</body>
</html>用鼠标点击只显示"onmousedown";貌似onmusedown后onclick没有执行?<!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>
function onMouse(){
//alert("onmousedown");
var str="现在取消alert":
}
function onClic(){
alert("onClick");
}
</script>
</head>
<body>
<input id="btn" type="button" value="点击" onmousedown="onMouse()" onclick="onClic()" />
</body>
</html>
显示“onClick”,现在onclick就执行了,为何少了onmusedown里的alert后oncick就执行了?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function onMouse(){
alert("onmousedown");
}
function onClic(){
alert("onClick");
}
</script>
</head>
<body>
<input id="btn" type="button" value="点击" onmousedown="onMouse()" onclick="onClic()" />
</body>
</html>用鼠标点击只显示"onmousedown";貌似onmusedown后onclick没有执行?<!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>
function onMouse(){
//alert("onmousedown");
var str="现在取消alert":
}
function onClic(){
alert("onClick");
}
</script>
</head>
<body>
<input id="btn" type="button" value="点击" onmousedown="onMouse()" onclick="onClic()" />
</body>
</html>
显示“onClick”,现在onclick就执行了,为何少了onmusedown里的alert后oncick就执行了?
<!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>
function onMouse(){
//alert("onmousedown");
var str="现在取消alert";
}
function onClic(){
alert("onClick");
}
</script>
</head>
<!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 type="text/javascript">
var n = 0;
function onMouse(){
n = 2;
}
function onClic(){
alert(n);
}
</script>
</head><body>
<input id="btn" name="btn" type="button" value="点击" onmousedown="onMouse()" onclick="onClic()" />
</body>
</html>
onclick行为会触发两个事件,一个是mousedown, 一个是mouseup.
onmousedown只会触发一个事件,即mousedown.在你的程序中,当mousedown事件触发的时候,突然alert弹出了一个窗口,此时事件中止,随后弹出的窗口接受了新的点击事件,前一个事件终止.于是onclick的mouseup事件也就没有了,所以感觉onclick好像没有触发事件一样.请注意结贴!
onclick行为会触发两个事件,一个是mousedown, 一个是mouseup.
onmousedown只会触发一个事件,即mousedown.在你的程序中,当mousedown事件触发的时候,突然alert弹出了一个窗口,此时事件中止,随后弹出的窗口接受了新的点击事件,前一个事件终止.于是onclick的mouseup事件也就没有了,所以感觉onclick好像没有触发事件一样.请注意结贴!
onclick行为会触发两个事件,一个是mousedown, 一个是mouseup.
onmousedown只会触发一个事件,即mousedown.在你的程序中,当mousedown事件触发的时候,突然alert弹出了一个窗口,此时事件中止,随后弹出的窗口接受了新的点击事件,前一个事件终止.于是onclick的mouseup事件也就没有了,所以感觉onclick好像没有触发事件一样.请注意结贴!
当你mousedown事件发生,你在函数里写了alert()弹出窗口此时焦点转到弹出窗口,
中止了onclick事件
请结贴·