易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript面向对象 继承












javascript面向对象继承的三种方法:
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
 
>
<
head runat
=
"
server
"
>
    
<
title
>
Untitled Page
</
title
>
    
<
script language
=
"
javascript
"
 type
=
"
text/javascript
"
>
    
//
基类
    function Person()
    
{
        
this
.Name
=
"
Person
"
;
        
this
.Sex
=
"
NONE
"
;
        
this
.Age
=
"
?
"
;
        
this
.SayName
=
function()
{alert(
this
.Name);}
;
        
this
.SaySex
=
function()
{alert(
this
.Sex);}
;
        
this
.SayAge
=
function()
{alert(
this
.Age);}
;
    }
    
//
子类
    function ManPerson()
    
{   
        
this
.Name
=
"
ManPerson
"
;
        
this
.Sex
=
"
Man
"
;
        
this
.Age
=
"
20
"
        Person.apply(
this
);
//
执行该语句时会调用Person中的构造器,先前赋值的ManPerson,Man,20就失去作用了,所以这句话
        
//
要放在this.Name="ManPerson";之前才能即继承Person的方法,又不会覆盖我们的赋值操作。
    }
    
    
//
第一种方法
 


相关文档:

javascript中eval用法

eval可以将字符串生成语句执行,和SQL的exec()类似。
eval的使用场合是什么呢?有时候我们预先不知道要执行什么语句,只有当条件和参数给时才知道执行什么语句,这时候eval就派上用场了。举个例子:
我们要做一个function(),功能是输入网页中两个个对象的名称,然后程序就将这两个对象的值联接起来输出。
function ou ......

JavaScript设置代码延时执行

//让某段代码延时执行
function delayRun(code, time) {
        var t = setTimeout(code, time);
}
应用举例:
<input type="button" name="query" value="统计" class="long_button" onClick="return delayRun('onQuery()', 1000);"> ......

javascript变化的时钟

<script language="JavaScript">
<!--
function check(val){
 if (val<10){
  return("0"+val);
 }else{
  return(val);
 }
}
function ShowTime()
{
 var date=new Date();
 var year=date.getFullYear();
 var month=date.getMont ......

JavaScript中最常用的55中技巧

1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)> <td>no </table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4. oncopy="return false;" oncut="re ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号