May
16
1.第一种方式,冒充对象的方式.(利用js里的每一个方法名都是一个Function对象)
//第一种方式,冒充对象的方式.(利用js里的每一个方法名都是一个Function对象)
function Parent(username){
this.username = username;
this.say = function(){
alert(this.username);
}
}
function Child(username,password){
this.temp = Parent;//temp指向Parent所指向的地方 。 利用js里的每一个方法名都是一个Function对象,指向一个方法。
this.temp(username);//初始化方法里的内容
delete this.temp;//temp没有用了。可以直接删除掉.this不可以丢了
//Parent(username);//这样写表面看起来是正确的,其实是错误的。因为只有new出来的对象才有this,所以调用Parent里的this就没有值了
this.password = password;
this.hello = function(){
alert(this.password);
}
}
var parent = new Parent("zhangsan");
parent.say();//zhangsan
var child = new Child("lisi","123456");
child.say();//lisi
child.hello();//123456
function Parent(username){
this.username = username;
this.say = function(){
alert(this.username);
}
}
function Child(username,password){
this.temp = Parent;//temp指向Parent所指向的地方 。 利用js里的每一个方法名都是一个Function对象,指向一个方法。
this.temp(username);//初始化方法里的内容
delete this.temp;//temp没有用了。可以直接删除掉.this不可以丢了
//Parent(username);//这样写表面看起来是正确的,其实是错误的。因为只有new出来的对象才有this,所以调用Parent里的this就没有值了
this.password = password;
this.hello = function(){
alert(this.password);
}
}
var parent = new Parent("zhangsan");
parent.say();//zhangsan
var child = new Child("lisi","123456");
child.say();//lisi
child.hello();//123456
May
15
javascript里构建类主要有4种方式
1.构造方式定义类
2.原型方式定义类
3.构造和原型结合方式创建类
4.动态的原型方式
各有优缺点,具体如下
1.构造方式定义类,优点:多个实例对象不共享类的属性值,缺点:每个实例对象都会产生出一个函数say
1.构造方式定义类
2.原型方式定义类
3.构造和原型结合方式创建类
4.动态的原型方式
各有优缺点,具体如下
1.构造方式定义类,优点:多个实例对象不共享类的属性值,缺点:每个实例对象都会产生出一个函数say
May
14
Float(浮动)概念也许是CSS中最让人迷惑的一个概念吧。Float经常被错误理解,而且因为将上下文元素全部浮动导致的可读性、可用性问题备受责难。然而,这些问题的根源并不在于理论本身,而是开发人员以及浏览器对理论的解读造成的。
如果你认真的去读一下浮动概念,你会发现并不像所见的那样复杂。大多数问题都是由于老版本的IE带来的(我只是猜想)。如果你知道这些bug,你就能避免这些问题。
让我们尝试去解决这些问题并澄清一些以前使用浮动的误解。我们参考了成打的相关文章,并选取了最为重要的一些你必须了解的问题。
May
13
1.
User = function (){
}
User.prototype.name = "zhangsan";
//User.name = "zhangsan";//错误定义
var u = new User();
u.password = "123456";
//u.prototype.password = "987654";//错误定义
alert(u.name);
alert(u.password);
}
User.prototype.name = "zhangsan";
//User.name = "zhangsan";//错误定义
var u = new User();
u.password = "123456";
//u.prototype.password = "987654";//错误定义
alert(u.name);
alert(u.password);
May
12
1.js不支持重载,因为js里的函数都是一个对象,js里有个隐含对象Function,所有的js函数都是一个Function类型的对象。比如:
等价于
function add(number)
{
alert("hello");
}
function add(number)
{
alert("hello");
}
{
alert("hello");
}
function add(number)
{
alert("hello");
}
等价于
var add = new Function("number","alert('hello');");
var add = new Function("number","alert('hello');");
var add = new Function("number","alert('hello');");
May
9
1. 集合类对象问题
现有代码中许多集合类对象取用时使用 (),IE 能接受,Firefox 不能。
解决方法:改用 [] 作为下标运算。如:document.forms("formName") 改为
2. DIV对象
在 IE 中,DIV对象可以使用ID作为对象变量名直接使用。在 Firefox 中不能。
DivId.style.display = "none";
解决方法:document.getElementById("DivId").style.display = "none";
ps:得对象的方法不管是不是DIV对象,都应该使用getElementById方法。
现有代码中许多集合类对象取用时使用 (),IE 能接受,Firefox 不能。
解决方法:改用 [] 作为下标运算。如:document.forms("formName") 改为
document.forms["formName"];
//又如:
document.getElementsByName("inputName")(1);
//改为
document.getElementsByName("inputName")[1];
//又如:
document.getElementsByName("inputName")(1);
//改为
document.getElementsByName("inputName")[1];
2. DIV对象
在 IE 中,DIV对象可以使用ID作为对象变量名直接使用。在 Firefox 中不能。
DivId.style.display = "none";
解决方法:document.getElementById("DivId").style.display = "none";
ps:得对象的方法不管是不是DIV对象,都应该使用getElementById方法。
May
2
JSP内置对象(9个常用的内置对象)
1.request对象
客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。它是HttpServletRequest类的实例。
序号 方 法 说 明
1 object getAttribute(String name) 返回指定属性的属性值
2 Enumeration getAttributeNames() 返回所有可用属性名的枚举
3 String getCharacterEncoding() 返回字符编码方式
4 int getContentLength() 返回请求体的长度(以字节数)
1.request对象
客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。它是HttpServletRequest类的实例。
序号 方 法 说 明
1 object getAttribute(String name) 返回指定属性的属性值
2 Enumeration getAttributeNames() 返回所有可用属性名的枚举
3 String getCharacterEncoding() 返回字符编码方式
4 int getContentLength() 返回请求体的长度(以字节数)






