<script language="JavaScript">
function getValue(){
  return 0;
}
</script>
<input type="text" name="t1" value="" onfocus="if(this.value == '') this.value = getValue();">

解决方案 »

  1.   

    <body>
    <input type="text" name="t1" value="">
    <script>
    window.onload = getValue;
    function getValue(){
      document.all.t1.value = 0;
    }
    </script>
    </body>
      

  2.   

    <body onload="t1.value=getValue()">
    <input type="text" name="t1" value="">
    </body>
    <script>
    function getValue(){
      return 0;
    }
    </script>
    function 一定要通過一些事件去觸發的
      

  3.   

    <input type="text" name="t1" value="" size="20" onfocus="this.value=getValue()">
    <script language="javascript">
    function getValue(){
      return 0;
    }
    </script>