日期:2014-05-16  浏览次数:20383 次

如何使用表单结合javascript改变网页图片的大小?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>images对象</title>

<script language="javascript1.2">
{
  function image()
  {
  document.images[0].border = document.form1.border.value ;
document.images[0].width = document.form1.width.value ;
document.images[0].height = document.form1.height.value ;
// document.write(document.images[0].border+" "+document.images[0].width+" "+document.images[0].height);
  }
}
</script>

</head>

<body>

<p><img src="2.jpg" alt="image图片" width="" height="" border="" name="myimg" /></p>
<form name="form1">
<p>
边框值<input type="text" name="border" size="5" />
宽度<input type="text" name="width" size="5" />
高度<input type="text" name="height" size="5" />
<input type="submit" value="提交" onclick="image()" />
<input type="reset" value="重置" />
</p>
</form>

</body>
</html>

测试结果是:一旦按了提交按钮,图片闪一下,接着就变回原来的大小了,这个为什么会这样的?

------解决方案--------------------
探讨
http://q.cnblogs.com/q/41004/
但为什么页面会自动刷新的?这个真的不懂,真心请教...[size=16px][/size]