此脚本在每个鼠标事件上对图像进行“翻转”,例如鼠标悬停并单击
img src 已更改,问题是我试图延迟 onClick 事件执行的函数的执行。
我试图将功能更改为 settimeout 但没有成功
setTimeOut('functionName(param1, param2)', 5000);
不调用封装设置超时的函数
我究竟做错了什么 ?
<a href="yourpage.htm">
<img src="images/Button2_Normal.PNG" width="150" id="img2"
onmouseover="mOver(this, image2)" onmouseout="mOut(this, image2)" onclick="mActive(this, image2)" />
</a>
<a href="yourpage.htm">
<img src="images/Button1_Normal.PNG" width="150" id="img1"
onmouseover="mOver(this, image1)" onmouseout="mOut(this, image1)" onclick="mActive(this, image1)">
</a>
javascript
var image1 = new Array("images/Button1_Normal.PNG", "images/Button1_MouseClick.PNG", "images/Button1_MouseOver.PNG"); var image2 = new Array("images/Button2_Normal.PNG", "images/Button2_MouseClick.PNG", "images/Button2_MouseOver.PNG"); var preloadImages = new Array(); // preloads images function Loadimages(images) { for (i = 0; i < images.length; i++) { preloadImages[i] = new Image() preloadImages[i].src = images[i] } } Loadimages(image1); lastN = "" function mOver(obj, images) { if (lastN != obj.id) { document.images[obj.id].src = (images.length == 3 ? images[2] : images[1]) } } function mOut(obj, images) { if (lastN != obj.id) { document.images[obj.id].src = images[0] } } function mActive(obj, images) { var ts1 = document.getElementById('img1'); if (typeof obj != "string") { obj = obj.id } document.images[obj].src = images[1] if (lastN != "" && lastN != obj) { document.images[lastN].src = images[0] } lastN = obj } function timeout_init(obj,images) { setTimeout('mActive(obj, images)', 5500); }