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

javascript写类方式之九

9、YUI的写类方式
这里引入的是YUI 2.7.0版,只需引入yahoo.js。YUI引入了命名空间,类似于java的包。以下yahoo的工具函数包
YAHOO.namespace
YAHOO.lang
YAHOO.lang.hasOwnProperty
YAHOO.lang.extend
YAHOO.lang.augment
YAHOO.log
YAHOO_config and YAHOO.env
YUI Module Names
写类方式:
//定义包名
YAHOO.namespace("test");
//定义类
YAHOO.test.Person = function(name) {
this.name = name;
}
YAHOO.test.Person.prototype.setName = function(name){ this.name = name;}
YAHOO.test.Person.prototype.getName = function(){ return this.name;}
//创建一个对象
var p = new YAHOO.test.Person("jack");
console.log(p.getName());//jack
p.setName('tom');
console.log(p.getName());//tom
//测试instanceof及p.constructor是否正确指向了YAHOO.test.Person
console.log(p instanceof YAHOO.test.Person);
console.log(p.constructor == YAHOO.test.Person);

可以看出除了多了包名,与第三种写类方式
并无区别。


相关文档:

javascript typeof的用法

javascript typeof的用法
经常会在js里用到数组,比如 多个名字相同的input, 若是动态生成的, 提交时就需要判断其是否是数组.
if(document.mylist.length != "undefined" ) {} 这个用法有误.
正确的是 if( typeof(document.mylist.length) != "undefined" ) {}
或 if( !isNaN(document.mylist.length) ) {}
typeof的运 ......

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 开发工具


Build your web applications quickly and easily using the industry leading web application IDE -- Aptana Studio.
Introduction:
Aptana Studio is a complete web development environment that combines powerful authoring tools for HTML, CSS, and JavaScript, along with thousands of additional plugins ......

JavaScript 判断checkbox取值问题

要取什么值?
取value:getElementById("STB_433").value;
取状态(是否check):getElementById("STB_433").checked
取ID:getElementById("STB_433").id
...
var checkboxs=document.getElementsByTagName("input");
var i;
for(i=0;i<checkboxs.length;i++)
{
if(checkboxs[i].type=='checkbox')
{ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号