少年阿宾

那些青春的岁月

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
第一种:最基本的作为一个本本分分的函数声明使用。
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Validate Page</title>
</head>
<script type="text/javascript">
function validate(abin){
    var lee=function(parameter){
        return 'hello,'+abin;
    }(abin);
    document.getElementById("spanId").innerHTML=lee;
}
</script>

<body>
    <div id="divId" class="divs">
        <input id="button" type="button" value="请猛击" onclick="validate('varyall')"/>
    </div>
    <br/>
    <span id="spanId" class="spans"></span>
</body>
</html>
 


第二种:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Validate Page</title>
</head>
<script type="text/javascript">
var validate=function(abin){
    var lee=function(parameter){
  return 'hello,'+parameter;
 }(abin);
 document.getElementById("spanId").innerHTML=lee;
};
</script>
<body>
 <div id="divId" class="divs">
  <input id="button" type="button" value="请猛击" onclick="validate('varyall')"/>
 </div>
 <br/>
 <span id="spanId" class="spans"></span>
</body>
</html>


第三种:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Validate Page</title>
</head>
<script type="text/javascript">
var validate=new Function("abin",
  "var lee=function(parameter){return 'hello,'+parameter;}(abin);document.getElementById('spanId').innerHTML=lee;");
</script>
<body>
 <div id="divId" class="divs">
  <input id="button" type="button" value="请猛击" onclick="validate('who')"/>
 </div>
 <br/>
 <span id="spanId" class="spans"></span>
</body>
</html>

posted on 2013-09-06 13:44 abin 阅读(400) 评论(0)  编辑  收藏 所属分类: Javascript

只有注册用户登录后才能发表评论。


网站导航: