当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript 个人笔记(没有整理,很乱)

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 个人笔记(没有整理,很乱)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 40 ::
收藏到网摘: n/a

==============关于元素的显示和隐藏=============
Visibility快于Display
让图画时隐时现会创造很有趣的效果,有2种方法可以实现这个目的:使用CSS的visibility属性或者
display属性。对于绝对位置元素,diaplay和visibility具有同样的效果。两者的区别在于:设置为
display:none的元素将不再占用文档流的空间,而设置为visibility:hidden的元素仍然保留原位置。
==============一点经验=======================
1、JS变量没有块作用域,在判断循环中的定义在整个函数内都有定义
2、split()的参数是一个正则字符串,因此如果用郑泽表达式特殊字符作为参数时一定要转义
=============隐去浏览器中当鼠标移到图片上跳出的工具栏=============
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
=============一些技巧==================
1、#连接不会回到顶部
<a href="#" ōnClick="return false">
---------------
2、关闭不提示
opener=null;
window.close();
============js面向对象编程的一些总结=============
1、静态属性类实例访问不到,同样实例属性只能实例访问
var myfun=function(){this.a="a"};
myfun.b="b";
alert(new myfun().a);//输出a
alert(myfun.a);//输出undefined
alert(myfun.b);//输出b
alert(new myfun().b);//输出undefined
2、给prototype添加属性
添加给prototype的属性将会成为使用这个构造函数创建的对象的通用属性。
function Fish(name, color)
{
this.name=name;
this.color=color;
}
Fish.prototype.livesIn="water";
Fish.prototype.price=20;
正如上面的例子所示,每条实例鱼可以有不同的名字和颜色,但是他们有一个共同的属性,那就是都生活在水里。
这时因为当一个对象被创建时,这个构造函数将会把它的属性prototype赋给新对象的内部属性__proto__。这个__proto__被这个对象用来查找它的属性。
3、用prototype给对象添加函数
通过prototype来给所有对象添加共用的函数。这有一个好处:你不需要每次在构造一个对象的时候创建并初始化这个函数。
4、每个函数都有一个静态name属性(同样,每个内置类都有一个静态name属性),这个属性不能也不会被覆盖
function a()={};
var b=new Function();
alert(b.name);//输出anonymous
alert(a.name);//输出a
alert(Array.name);//输出Array
==================关于this==================
之所以说一下this,是因为他并不完全等同于C++或者Java里面的this变量。
this在js中表示紧贴着调用地点的,非prototype扩展的方法。
比如上面提到的
MyObj.prototype.sayBye = function () {
alert(”Bye” + this.name);
}
这个里面的this,紧贴的非prototype的函数是MyObj(再次注意,js中class是通过函数实现的),所以this.name就是实例变量。
但是在这种情况
MyObj.prototype.doSomething = function () {
todo(function () {
alert(this.name);
});
}
这个时候,this表示的是这个匿名函数
function () {
alert(this.name)
}
那么这里就会出现错误,如果想要这样使用,应该使用辅助变量。
MyObj.prototype.doSomething = function () {
var me = this; //把自己的reference赋值给变量me
todo (function () {
alert(me.name); //通过me来访问myObj实例
});
}