我要使程序实现当鼠标移向图片时,触发onmouseover事件,调用函数mouseOver()执行,程序就更换新的图片,当鼠标移出图片时,触发onmouseout事件,调用mouseOut()执行,恢复为原来的图片;另外,当按下鼠标按键时,触发body 的onmousedown事件,调用函数mousePressd(),弹出警告框。
程序如下:
<html>
<head>
<script type ="text/javascript">
function mouseOver(){
document.mouse.src ="file:///D|/我的文档/12.jpg" width="100" />
}
function mouseOut(){
document.mouse.src="file:///D|/我的文档/2.jpg" width="100" >
}
function mousePressd(event){
if (event.button= =2){
alert("您单击了鼠标右键!")
}else{
alert("您单击了鼠标左键!")
}
}
</script>
<title>无标题文档</title>
</head><body onmousedown ="mousePressd(event)">
<img border ="0" src ="file:///D|/我的文档/2.jpg" width="100" name="mouse" onmouseover ="mouseOver()" onmouseout ="mouseOut()" />
</body>
</html>
程序如下:
<html>
<head>
<script type ="text/javascript">
function mouseOver(){
document.mouse.src ="file:///D|/我的文档/12.jpg" width="100" />
}
function mouseOut(){
document.mouse.src="file:///D|/我的文档/2.jpg" width="100" >
}
function mousePressd(event){
if (event.button= =2){
alert("您单击了鼠标右键!")
}else{
alert("您单击了鼠标左键!")
}
}
</script>
<title>无标题文档</title>
</head><body onmousedown ="mousePressd(event)">
<img border ="0" src ="file:///D|/我的文档/2.jpg" width="100" name="mouse" onmouseover ="mouseOver()" onmouseout ="mouseOut()" />
</body>
</html>
<html>
<head>
<script type ="text/javascript">
function mouseOver(){
document.mouse.src ="last.gif"
}
function mouseOut(){
document.mouse.src="file:///D|/我的文档/2.jpg"
}
function mousePressd(event){
if (event.button==s2){
alert("您单击了鼠标右键!")
}else{
alert("您单击了鼠标左键!")
}
}
</script>
<title>无标题文档</title>
</head><body onmousedown ="mousePressd(event)">
<img border ="0" src ="file:///D|/我的文档/2.jpg" width="100" name="mouse" onmouseover ="mouseOver()" onmouseout ="mouseOut()" />
</body>
</html>
<head>
<script type ="text/javascript">
function mouseOver(){
document.mouse.src ="2.jpg"
}
function mouseOut(){
document.mouse.src="1.jpg"
}
function mousePressd(event){
if (event.button==2){
alert("您单击了鼠标右键!")
}else{
alert("您单击了鼠标左键!")
}
}
</script>
<title>无标题文档</title>
</head><body onmousedown ="mousePressd(event)">
<img border ="0" src ="1.jpg" width="236" name="mouse" onmouseover ="mouseOver()" onmouseout ="mouseOut()" height="316" />
</body>
</html>
document.mouse.src ="file:///D|/我的文档/12.jpg";3、document.mouse.src="file:///D|/我的文档/2.jpg" width="100" >这行改为
document.mouse.src="file:///D|/我的文档/2.jpg";