青草堂
研究javascript的几个例子(一)
关键字:构造继承,prototype
JS.js文件:
function
BaseClass()
{
this
.name
=
"
BaseClass
"
;
//
this.prototype.Height="1.5米"; 错误写法
BaseClass.prototype.Height
=
"
1.5米
"
;
this
.Width
=
"
2米
"
;
this
.Weight
=
"
1吨
"
;
this
.say
=
function
()
{
return
"
my name is
"
+
this
.name
+
"
,Height:
"
+
this
.Height
+
"
,Width:
"
+
this
.Width
+
"
,Weight:
"
+
this
.Weight;
}
}
function
SonClass()
{
this
.base
=
BaseClass;
this
.base();
this
.Weight
=
"
2吨
"
;
this
.Color
=
"
red
"
;
this
.Title
=
"
SonClass
"
;
this
.loudsay
=
function
()
{
return
"
my name is
"
+
this
.Title
+
"
,Height:
"
+
this
.Height
+
"
,Width:
"
+
this
.Width
+
"
,Weight:
"
+
this
.Weight
+
"
,Color:
"
+
this
.Color;
}
}
SonClass.prototype.Speed
=
"
100
"
;
SonClass.prototype.run
=
function
()
{
return
"
my name is
"
+
this
.Title
+
"
,Height:
"
+
this
.Height
+
"
,Width:
"
+
this
.Width
+
"
,Weight:
"
+
this
.Weight
+
"
,Color:
"
+
this
.Color
+
"
,Speed:
"
+
this
.Speed;
}
HTML:
<
html
>
<
head
>
<
title
></
title
>
<
script
src
=jS.js
type
="text/javascript"
></
script
>
<
script
language
=javascript
>
//
BaseClass baseclass = new BaseClass();错误写法
var
baseclass
=
new
BaseClass();
alert(baseclass.name);
//
Base
alert(baseclass.say());
//
my name is BaseClass,Height:1.5米,Width:2米,Weight:1吨
var
Son
=
new
SonClass();
alert(Son.say());
//
my name is BaseClass,Height:undefined,Width:2米,Weight:2吨
alert(Son.loudsay());
//
my name is SonClass,Height:undefined,Width:2米,Weight:2吨,Color:red
alert(Son.run());
//
my name is SonClass,Height:undefined,Width:2米,Weight:2吨,Color:red,Speed:100
SonClass.prototype.Height
=
"
2.5米
"
;
alert(Son.run());
//
my name is SonClass,Height:2.5米,Width:2米,Weight:2吨,Color:red,Speed:100
</
script
>
</
head
>
<
body
>
</
body
>
</
html
>
posted on 2008-06-02 10:26
青羽
阅读(193)
评论(1)
编辑
收藏
所属分类:
B
√
JavaScript
评论
#1楼
2008-06-02 12:03
求知无傲
飘一下。
回复
引用
查看
新用户注册
刷新评论列表
标题
姓名
主页
Email
(博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
博客园首页
新闻频道
社区
小组
博问
网摘
闪存
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
该文被作者在 2008-06-02 10:32 编辑过
成果网帮您增加网站收入
相关文章:
javascript小技巧
深入浅出之正则表达式(一)
悟透JavaScript
javascript小技巧&&JavaScript[对象.属性]集锦 [转载了多篇]
ASP.NET AJAX入门系列(4):使用UpdatePanel控件(一)
用C#编写ActiveX控件(一)
相关链接:
所属分类的其他文章:
javscript中的数组-您知道他们的值吗?
研究javascript的几个例子(一)
Asp.Net引用JS文件出现乱码
超棒的Ext!
Javascript模态窗口实现
window.open刷新页面
调用web service 遇到的错误
调试javascript很easy啊!
传对象与传串_简单介绍
服务器端执行javascript脚本
最新IT新闻:
JavaScript将成Silverlight的最大对手?
没有谷歌就活不下去的四个网站
Google 10周岁生日
祝Google 10周岁生日快乐
Google十年市值达1500亿美元 创造奇迹
导航
博客园
首页
新随笔
联系
订阅
管理
公告
流量
V
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的文章
我的参与
最新评论
我的标签
留言簿
给我留言
查看留言
我参与的团队
SharePoint团队(0/733)
DNN团队博客(0/325)
.NET 控件与组件开发(0/1370)
ASP.NET AJAX (Atlas)学习(0/1347)
报表与图表团队(0/176)
O/R Mapping团队(0/207)
Silverlight学习与研究(0/286)
数据库团队(0/252)
博客园创业者(0/47)
随笔分类
(210)
A
√
DHTML(3)
(rss)
B
√
JavaScript(15)
(rss)
C
√
Prototype(1)
(rss)
D
√
JQuery
(rss)
E
√
Ajax(6)
(rss)
F
√
XML(13)
(rss)
G
√
O/R Mapping(5)
(rss)
H
√
Hibernate&Spring(4)
(rss)
I
√
SharePoint(18)
(rss)
J
√
都是DotNet(51)
(rss)
K
√
Java起步(4)
(rss)
L
√
SQL Server(23)
(rss)
M
√
数据结构(1)
(rss)
N
√
CLR Via(27)
(rss)
O
√
CallCenter(1)
(rss)
P
√
UML(1)
(rss)
Q
√
SilverLight
(rss)
R
√
LINQ
(rss)
S
√
技术之外(28)
(rss)
T
√
Community Server
(rss)
U
√
好文转载(3)
(rss)
V
√
Oracle(1)
(rss)
W
√
计算机基础(2)
(rss)
X
√
SNS研究(3)
(rss)
Y
√
PetShop
(rss)
随笔档案
(180)
2008年9月 (1)
2008年8月 (1)
2008年7月 (6)
2008年6月 (10)
2008年5月 (22)
2008年4月 (9)
2008年3月 (5)
2008年2月 (1)
2008年1月 (1)
2007年12月 (2)
2007年11月 (1)
2007年10月 (1)
2007年9月 (1)
2007年8月 (1)
2007年7月 (11)
2007年6月 (4)
2007年5月 (7)
2007年4月 (7)
2007年3月 (2)
2007年2月 (2)
2006年12月 (3)
2006年11月 (19)
2006年10月 (27)
2006年9月 (36)
文章分类
(31)
北京房子(3)
(rss)
网上拾贝(28)
(rss)
收藏夹
(147)
博客及站点收藏(35)
(rss)
交流类网站(23)
(rss)
我的收藏(89)
(rss)
互联网
keso-5g
阿北-豆瓣
飞扬新锐--贝壳
蒋涛--CSDN
老白--5g
李彦宏--baidu
刘韧--DoNews
麦田-蚂蚁
孟岩--财帮子
腾讯_总裁俱乐部
圈内
Scott Guthrie
Scott Guthrie中文
visibone
金雪根
李建忠
孟子E章
友情链接
Beyond歌迷社区
Lee-hp
QQ博客
小熊
园内
Felix
怪怪
彭斌
张逸
积分与排名
积分 - 78957
排名 - 511
最新评论
1. re: 好玩的SNS(一)
哈哈 看看 顺便支持下
--随缘吧
2. re: 怎样在javascript函数中将变量传递给服务端脚本程序?
写的真好,一下明白了。
--nicedi
3. re: MSN 与六度分隔理论
最近联系到一个初中同学曾追的隔壁班女孩
发现她的爸爸的上山下乡时的一个老友是濮存昕
然后我就信这个了
--斯克迪亚
4. re: 专家门诊——ASP.NET开发答疑200问
不错
--X3
5. re: McAfee无法更新病毒库
找不到Network Associates.
--YMZ100
6. re: JavaScript总结(2)-网页上显示时间
ddgg fssfskjky
--不管值不值得我都会爱你到老
7. re: 免费得QQ秀
要好看
--柏拉图D爱恋
8. re: 资源收集
mark.
--傲然林
9. re: 免费得QQ秀
我想要个好的QQ秀... 希望能满足我`` 黑客的小子`就别想来套号` 本QQ早以设有木马`~~...
--沈
10. re: Javascript模态窗口实现
好东西!谢谢
--stg609
11. re: 获取某命名规则下一系列表的总条数
不用那么复杂的了。Use TestgoDeclare @T Table(id int Identity(1,1),ObjectName nvarchar(128),Total int)Insert I...
--OK_008
阅读排行榜
1. 史努比 2.0轻松搞定pci.sys丢失(2727)
2. sql统计-关于学生成绩(1783)
3. 专家门诊——ASP.NET开发答疑200问(1583)
4. SharePoint初探-SharePoint,WSS,SPS概述(1)(1357)
5. Javascript模态窗口实现(1315)
评论排行榜
1. 专家门诊——ASP.NET开发答疑200问(17)
2. 寻找asp.net2.0空间~~(11)
3. sql统计-关于学生成绩(10)
4. Gmail邀请(9)
5. 出差小记(一)(7)