易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript写类方式之五

5、用 构造函数+原型 定义一个类;同一构造函数可以定义出多个类型



/**
* $define 写类工具函数之二
* @param {Object} constructor
* @param {Object} prototype
*/
function $define(constructor,prototype) {
var c = constructor || function(){};
var p = prototype || {};
return function() {
for(var atr in p)
arguments.callee.prototype[atr] = p[atr];
c.apply(this,arguments);
}
}

与第四种方式类似,仍然用构造函数,原型对象,定义两个类。
//构造函数
function Person(name) {
this.name = name;
}
//原型对象
var proto = {
getName : function(){return this.name},
setName : function(name){this.name = name;}
}
//定义两个类
var Man = $define(Person,proto);
var Woman = $define(Person,proto);
console.log(Man == Woman);//false,同一个构造函数(Person)定义不同的类


相关文档:

javascript中几种操作打印的方法

1 局部打印方法:
作用:将id为dayin的内容,新建页面并打印,可解决打印某页面中的部分内容的问题。
使用方法:将要打印的内容通过 <span id="dayin"></span>包含起来,然后在某个按扭中定义
事件
<input type="button" onclick="dayin()" value="打印">
function dayin()  
{
  ......

javascript的一些工具

JS Check:
javascriptlint http://www.javascriptlint.com/index.htm
jslint http://www.jslint.com/
JS UT:
http://www.jsunit.net/
JS ST:
http://www.outofhanwell.com/ieleak/index.php?title=Main_Page Drip
http://blogs.msdn.com/gpde/pages/javascript-memory-leak-detector.aspx
http://blogs.msdn. ......

JavaScript静态页面值传递之Cookie

  利用Cookie:Cookie是浏览器存储少量命名数据.它与某个特定的网页或网站关联在一起。
  Cookie用来给浏览器提供内存,以便脚本和服务器程序可以在一个页面中使用另一个页面的输入数据。
  Post.htm
以下是引用片段:
<input type="text" name="txt1">
<input type="button" value="Post">
<s ......

javascript 验证代码整理

//the common event,If your brower is firefox,you should use this function instead of "window.event"
function getEvent() {
if(document.all)
return window.event; //get ie event
func=getEvent.caller;
while(func!=null) {
......

15个 JavaScript Web UI 库

几乎所有的富 Web 应用都基于一个或多个 Web UI 库或框架,这些 UI 库与框架极大地简化了开发进程,并带来一致,可靠,以及高度交互性的用户界面。本文介绍了 15 个非常强大的 JavaScript Web UI 库,非常适合各种各种规模的富 Web 应用的开发。
LivePipe
LivePipe UI 基于 Prototype Javascript 框架,包含了一整套经严 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号