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的方法,又不会覆盖我们的赋值操作。
}
//
第一种方法
相关文档:
eval可以将字符串生成语句执行,和SQL的exec()类似。
eval的使用场合是什么呢?有时候我们预先不知道要执行什么语句,只有当条件和参数给时才知道执行什么语句,这时候eval就派上用场了。举个例子:
我们要做一个function(),功能是输入网页中两个个对象的名称,然后程序就将这两个对象的值联接起来输出。
function ou ......
有许多小窍门来使编程更加容易。其中之一就是eval()函数,这个函数可以把一个字符串当作一个JavaScript表达式一样去执行它。以下是它的说明
Eval 函数
功能:先解释Javascript代码,然后在执行它
用法:Eval(codeString)
codeString是包含有Javascript语句的字符串,在eval之后使用Javascript引擎编译。
举个小例子:
......
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 ......
<script language="javascript">
//none表示不显示按钮
document.getElementById("transFund_bttn").style.display = "none";
document.getElementById("transFundGether_bttn").style.display = "none";
document.getElementById("payGether_bttn").style.display = "none";
function query(){
&n ......