javascript继承
用call方法实现继承
function classA(sColor){
this.color=sColor;
this.sayColor=function(){
alert(this.color);
}
}
function classC(sColor,sName){
classA.call(this,sColor);
this.name=sName;
this.sayName=function(){
alert(this.name);
}
}
var obj1=new classC("red","jack");
obj1.sayColor();
obj1.sayName();
用apply方法实现继承
function classD(sColor,sName){
classA.apply(this,new Array(sColor));
this.name=sName;
this.sayName=function(){
alert(this.name);
}
}
var obj2=new classD("blue","sherry");
obj2.sayColor();
obj2.sayName();
构造函数,原型混合方法
function classA(sName){
this.name=sName;
}
classA.prototype.sayName=function(){
alert(this.name);
}
function classB(sName,sHeight){
classA.call(this,sName)
this.height=sHeight;
}
classB.prototype=new classA();
classB.prototype.sayHeight=function(){
alert(this.height);
}
var obj3=new classA("jack");
obj3.sayName();
var obj4=new classB("shrry",27);&nbs
相关文档:
<script language="javascript">
<!--
String.prototype.replaceAll = stringReplaceAll;
function stringReplaceAll(AFindText,ARepText){
raRegExp = new RegExp(AFindText,"g");
return this.replace(raRegExp,ARepText)
}
var content = "%sfasf%sfd%asdfsadf%1111%"
// 把 所有的 % 替换为 #
......
  ......
if (elename.equalsIgnoreCase("back") || elename.equalsIgnoreCase("1"))
return "<a href=\"javascript:window.history.back()\">后退</a>";
&nbs ......
js验证表单大全
1. 长度限制
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("不能超过50个字符!");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"&g ......
1.document.write( " "); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document- >html- >(head,body)
4.一个浏览器窗口中的DOM顺序是:window- >(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById( "表单中元素的ID號 ").name(或value)
6 ......