js的变量的定义的讲解

来源:互联网 发布:神经网络 股票 知乎 编辑:程序博客网 时间:2024/04/29 03:16

1、常用的javascript脚本
jquery dojo ext js


<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()

+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'index.jsp' starting page</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
 <script type="text/javascript">
     //document.write("我爱你");
     //这是声明变量
     var i = 2;
     var i,j;
     var notNull = true;
     m = 10;
     /*alert(j);//结果是undefined
     alert(i);
     alert(m);
 alert(k);//这样会报错k没有定义
 */
     
     var s = 3;
     //alert(s);
     s = false;
     //alert(s);
     //全局变量、局部变量
     var globe = false;//全局变量
     function test()
     {
      var global = 'asd';//局部变量
      i = 123;//这是全局变量
      document.write(globe+"<br/>");
      document.write(global+"<br/>");
     }
     document.write(globe+"<br/>");
     document.write(global);
     
     
    </script>
//这是引入外部的js
   <!--  <script type="text/javascript" src="js/hello.js"></script>-->
  </head>
 
  <body>
   
  <a href="#" onclick="test();">点击</a>
  
  
  </body>
</html>

原创粉丝点击