JS控制图片大小,但是图片首次加载不能显示,需要刷新后才会正常,急急急啊 10
<inputname="productImage"type="image"id="productImage"src="images/aaa.jpg"onMouseMove...
<input name="productImage" type="image" id="productImage" src="images/aaa.jpg" onMouseMove="move()" onMouseOut="out()">
<script language="javascript">
var w=productImage.width;
var h=productImage.height;
productImage.height = h*0.5;
productImage.width = w*0.5;
function move()
{
productImage.height = h;
productImage.width = w;
}
function out()
{
productImage.height = h*0.5;
productImage.width = w*0.5;
}
</script> 展开
<script language="javascript">
var w=productImage.width;
var h=productImage.height;
productImage.height = h*0.5;
productImage.width = w*0.5;
function move()
{
productImage.height = h;
productImage.width = w;
}
function out()
{
productImage.height = h*0.5;
productImage.width = w*0.5;
}
</script> 展开
1个回答
2015-01-27
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8 />
<title>Nothing</title>
<style type="text/css">
</style>
</head>
<body>
<input name="productImage" type="image" id="productImage" src="images/aaa.jpg" onmouseover="move(this)" onmouseout="out(this)">
<script type="text/javascript">
productImage.onload = function ()
{
loading (this);
}
var loading = function (productImage)
{
var w = productImage.width;
败档 var h 察慧乱= productImage.height;
productImage.height = h * 0.5;
productImage.width = w * 0.5;
}
function move (productImage)
碧粗 {
productImage.height *= 2;
productImage.width *= 2;
}
function out (productImage)
{
productImage.height *= 0.5;
productImage.width *= 0.5;
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询