处理图像2

2016-10-19  本文已影响27人  味蕾里的青春

].parentNode',document.images[i].parentNode.tagName)
if (document.images[i].parentNode.tagName=="A"){
setupRollover(document.images[i]);
}
}
}

function setupRollover(thisImage) {
// console.log('setupRollover',thisImage)
var defaultUrl = thisImage.src;
thisImage.onmouseover=function () {
//console.log('vghgg')
thisImage.src="../img/"+thisImage.id+"arrow.jpg";
}

thisImage.onmouseout=function () {
    thisImage.src=defaultUrl;
}

thisImage.onclick=function() {
    thisImage.src="../img/"+thisImage.id+"three.gif";
}

}




 ###4.由链接触发翻转器
html:



<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-scale,initial-scale=1">
<link type="text/css" rel="stylesheet" href="../css/simple Rollover.css">
<script type="text/javascript" src="../js/link rollover.js"></script>
<title>link Rollover</title>
</head>
<body>
<h1>
<a href="http://hicc.me/" id="arrow">Next page</a>
</h1>
<img src="../img/bluearrow.jpg" id="arrowImg" alt="arrow">
</body>
</html>




js:




window.onload=rolloverInit;
function rolloverInit() {
for(var i=0;i<document.links.length;i++){
var defaultlink=document.links[i];
if (defaultlink) {
var defaultimg=document.getElementById(defaultlink.id+"Img");
if(defaultimg){
setupRollover(defaultlink,defaultimg);
}
}
}
}

function setupRollover(thisLink,thisImg){
var defaultUrl=thisImg.src;
thisLink.onmouseover=function(){
thisImg.src="../img/red"+thisLink.id+".jpg";
}

thisImg.onmouseout=function(){
    thisImg.src=defaultUrl;
}

thisImg.onclick=function(){
    thisImg.src="../img/green"+thisLink.id+".jpg";
}

}

上一篇下一篇

猜你喜欢

热点阅读