风故故,也依依

Stand still in the wind.

导航

JavaScript基础之变量的使用

<html>
    <head>
      <title>Examples of the var Keyword</title>
    <script language="JavaScript">
    <!--
    var myVar = "Global";

    function myFunc(){
      var myVar = "Function";
      return myVar;
    }

    function mySecFunc(){
      var myVar = "Second Function";
      document.write("<br>The value of myVar when called by mySecFunc() is: ");
      document.write(myVar);
    }
    -->
    </script>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    document.write("The value of myVar when called is: " + myVar)

    document.write("<br>The value of myVar when called by myFunc() is: ");

    document.write(myFunc());

    mySecFunc();

    -->
    </script>
    </body>
    </html>

posted on 2007-09-25 11:32  jadmin  阅读(170)  评论(0编辑  收藏  举报