javascript面向对象例子
来源:互联网 发布:中国移动流量充值端口 编辑:程序博客网 时间:2024/05/29 19:45
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.deng.testjs.model.Person"%>
<%
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">
/**
实现人、老师、学生之间的关系 并体现继承
*/
function test() {
var teacher = new Teacher();
alert("老师会说:" + teacher.say("同学们好"));
var student = new Student();
alert("学生会说:" + student.say("老师好"));
alert("老师去学校的目的是:" + teacher.goSchool());
alert("同学去学习的目的是:" + student.goSchool());
}
function Person() {
this.say = function(content) {
return content;
}
}
function Teacher() {
this.goSchool = function(){
return "教书育人";
}
}
function Student() {
this.goSchool = function(){
return "学习知识,实现梦想";
}
}
Teacher.prototype = new Person();
Student.prototype = new Person();
</script>
</head>
<body>
This is my JSP page. <br>
<input type="button" onClick="test()" value="test">
</body>
</html>
<%@page import="com.deng.testjs.model.Person"%>
<%
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">
/**
实现人、老师、学生之间的关系 并体现继承
*/
function test() {
var teacher = new Teacher();
alert("老师会说:" + teacher.say("同学们好"));
var student = new Student();
alert("学生会说:" + student.say("老师好"));
alert("老师去学校的目的是:" + teacher.goSchool());
alert("同学去学习的目的是:" + student.goSchool());
}
function Person() {
this.say = function(content) {
return content;
}
}
function Teacher() {
this.goSchool = function(){
return "教书育人";
}
}
function Student() {
this.goSchool = function(){
return "学习知识,实现梦想";
}
}
Teacher.prototype = new Person();
Student.prototype = new Person();
</script>
</head>
<body>
This is my JSP page. <br>
<input type="button" onClick="test()" value="test">
</body>
</html>
- javascript面向对象例子
- javascript 面向对象例子
- javascript(js) 面向对象的例子
- Javascript面向对象相关的一个例子
- JavaScript:一个面向对象的例子
- Javascript面向对象例子--下雪效果
- JavaScript:面向对象编程改装的例子
- Javascript 进阶 面向对象编程 继承的一个例子
- JS面向对象例子
- 面向对象的例子
- 面向对象-生活例子
- python面向对象例子
- lua面向对象例子
- javaScript 面向对象-对象
- javascript 面向对象初探
- JavaScript 面向对象编程
- JavaScript 面向对象编程
- 面向对象的javascript
- 如何减小与“大牛”的差距
- linux命令大全
- 纯CSS实现的3D简洁按钮设计
- WebLogic 11g默认用户密码
- Linux中文件的压缩与解压缩
- javascript面向对象例子
- ORACLE- join,inner join 与 left join, left outer join
- MySql 二进制相关(Blob)
- 国际标准智商测试题 (转载)
- GBin1在线实例帮助你更好的了解jQuery功能特性(三)
- linux操作
- git客户端配置
- UIImage扩展方法(category),支持放大和旋转
- 解决Fedora 15 下rar文件解压问题