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
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
JavaScript页面刷新与弹出窗口问题解决方法
1.无提示刷新网页
大家有没有发现,有些网页,刷新的时候,会弹出一个提示窗口,点“确定”才会刷新。
而有的页面不会提示,不弹出提示窗口,直接就刷新了.
如果页面没有form,则不会弹出提示窗口。如果页面有form表单,
a)< form method="post" ...&g ......
  ......
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.JavaScript中的对象
分为3种。
(1)JavaScript的内置对象
常用的有Date,Array,String,Math,对象,这些都是经常会用到的,一定要掌握好。
(2)文档对象模型(Document Object Model,DOM)
这个对象表示了当前浏览器的多个组件和当前的HTML文档。DOM我认为是JS中最重要的一个对象,通过他可以获得任何一个HTML元素 ......