function setupRollover(thisImage) { thisImage.outImage = new Image(); thisImage.outImage.src = thisImage.src; thisImage.onmouseout = function() { this.src =thisImage.outImage .src; } thisImage.clickImage = new Image(); thisImage.clickImage.src = "images/" + thisImage.id + "_click.gif"; thisImage.onclick = function() { this.src = thisImage.clickImage.src; } thisImage.overImage = new Image(); thisImage.overImage.src = "images/" + thisImage.id + "_on.gif"; thisImage.onmouseover = function() { this.src = thisImage.overImage.src; } }
最近在学习javascript,在书上看到了这样的一串代码,意思是鼠标在图片上,点击图片,不在图片上的效果,我不明的是为什么要定义outImage,clickImage,overImage,所以我改了一下代码
function setupRollover(thisImage) { temp = new Image(); temp.src = thisImage.src; thisImage.onmouseout = function() { this.src = temp.src; } temp.src = "images/" + thisImage.id + "_click.gif"; thisImage.onclick = function() { this.src = temp.src; } temp.src = "images/" + thisImage.id + "_on.gif"; thisImage.onmouseover = function() { this.src = temp.src; } }
发现不行,我不明白是为什么,请高人指点!
尚方宝剑之说
心有法竹
HUWWW
相关分类