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的方法,又不会覆盖我们的赋值操作。
}
//
第一种方法
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
substr 取部份字符串。 语法: string substr(string string, int start, int [length]); 返回值: 字符串 函数种类: 资料处理 内容说明 本函数将字符串 string 的第 start 位起的字符串取出 length 个字符。若 start 为负数,则从字符串尾端算起。若可省略的参数 length 存在,但为负数,则表示取到倒数第 length 个字 ......
43、JavaScript主页弹出窗口技巧
窗口中间弹出
<script>
window.open("http://www.cctv.com","","width=400,height=240,top="+(screen.availHeight-240)/2+",left="+(screen.availWidth-400)/2);
</script>
============
<html>
<head>
<script language="LiveScript">
fu ......
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 ......
JSON => String:
function jsonToString(obj){
var THIS = this;
switch(typeof(obj)){
case 'string':
return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';
case 'array':
return '[' + obj.map(THIS.jsonToStri ......