<!doctype html>
<html>
<head>
<title>获取样式</title>
<meta charset="UTF-8">
<!--<link rel="stylesheet" type="text/css" href="CSS/style.css">
<script type="text/javascript" src="Js/script.js"></script>-->
</head>
<body>
<div style="width:300px;margin: auto;">
<img src="images/heaven.png" id="myImages">
</div>
<script type="text/javascript">
window.onload=function(){
var oImg=document.getElementById('myImages');
oImg.onclick=function(){
alert("你好!");
maxFun();
}
}
var oImg=document.getElementById('myImages');
//定义放大函数
var maxwidth=oImg.width*2;
var maxheight=oImg.height*2;
function maxFun(){
var endwidth=oImg.width*1.3;
var endheight=oImg.height*1.3;
var maxTimer=setInterval(function(){
if (oImg.width<endwidth) {
if (oImg.width<maxwidth) {
oImg.width=oImg.width*1.05;
oImg.height=oImg.height*1.05;
} else{
clearInterval(maxTimer);
}
}else{
clearInterval(maxTimer);
}
},20);
}
</script>
</body>
</html>