<html>
<head>
<title>
</title>
</head>
<body onunload="pclose()" >
<img src="ss.jpg" name="img1" onload="blowup()" onmouseout="blowup()" onmouseover="reduce()">
<script language="javascript">
<!--
  var h=img1.height;
  var w=img1.width;
  function blowup(){
    if(img1.height>=h){
      img1.height=h-200;
      img1.width=w-200;
    }
  }
  function reduce(){
    if(img1.height<h){
      img1.height=h;
      img1.width=w;
    }
  }
  function pclose(){
    alert("欢迎浏览本网页");  
  }
  //-->
</script>
</body>
</html>
按照书上写的,但是事件就是不响应,已经几天了,愁得慌啊。各位路过的大哥大姐,给看看

解决方案 »

  1.   

    <!-- 导致js报错了,后面代码不执行
      

  2.   


    <body onunload="pclose()" >
    <img src="ss.jpg" id="img1" onload="imgload()" onmouseout="blowup()" onmouseover="reduce()">
    <script language="javascript">
    <!--
      var img1 = document.getElementById("img1");
      var h;
      var w;
      function imgload() {
        h=img1.height;
        w=img1.width;
       blowup();
      }
      function blowup(){
        if(img1.height>=h){
          img1.height=h-200;
          img1.width=w-200;
        }
      }
      function reduce(){
        if(img1.height<h){
          img1.height=h;
          img1.width=w;
        }
      }
      function pclose(){
        alert("欢迎浏览本网页");  
      }
      //-->
    </script>