Javascript 类和命名空间的定义
//1.类
function Test(id)
{
this.id=id;
this.method=function()
{
//代码
};
}
//可以继续扩展上面的方法:
Test.prototype.method1=function(){};
//调用写好的类 var A = new Test("1");
//2.JS命名空间
var namespace={};//var namespace=new Object();
o.i=4;
o.method1=function(){};
//我的想法是:就是利用object特性,可以添加自己的方法和变量,从而达到方便设置命名空间的目的;
//下面是网上的一个方法,我觉得这个比较方便,特别是命名空间的层次比较多的时候,用这个去注册,非常快
<script language="javascript" type="text/javascript">
// Namespace
Namespace =
new
Object();
// register"Grandsoft.GEA"
Namespace.register =
function
(fullNS)
{
// N, GrandsoftGEA
var nsArray = fullNS.split('.'
);
var sEval = ""
;
var sNS = ""
;
for (var
i = 0; i < nsArray.length; i++)
{
if (i != 0) sNS += "."
;
sNS += nsArray[i];
//
// GrandsoftGrandsoft.GEA
sEval +=
"if (typeof(" + sNS + ") == 'undefined') " + sNS +
" = new Object();"
}
if (sEval != ""
) eval(sEval);
}
//JavaScript
// Grandsoft.GEA, Grandsoft.GCM
Namespace.register(
"Grandsoft.GEA"
);
Namespace.register(
"Grandsoft.GCM"
);
// Grandsoft.GEAPerson
Grandsoft.GEA.Person =
function
(name, age)
{
this
.name = name;
this
.age = age;
}
// Personshow()
Grandsoft.GEA.Person.prototype.show =
function
()
{
alert(
this.name + " is " + this.age + " years old!"
);
}
// Person
var
p = new Grandsoft.GEA.Person("yanglf"
, 25);
window.onload = p.show;
</script>
相关文档:
我想使用过ajax的都常见这样的代码:
<a href="javascript:doTest2();void(0);">here</a>
但这儿的void(0)究竟是何含义呢?
Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值。
void 操作符用法格式如下:
1. javascript:void (expression)
2. javascript:void expression
expr ......
<html>
<head>
<mce:style><!--
.tvline{width:240px;height:180px;border:0;}
.tvline td{border-top:1 solid #000000;font:1px;filter:alpha(opacity=30)}
--></mce:style><style mce_bogus="1"> .tvline{width:240p ......
密码已经是我们生活工作中必不可少的工具,但一个不安全的密码有又有可能会给我们造成不必要的损失。作为网站设计者,如果我们在网页中能对用户输入的密码进行安全评估,并显示出相应的提示信息,那么对用户设置一个安全的密码将有很大帮助。同时也使得网站更具人性化,更有吸引力.
什么是一个安全的密码呢 ......
window
window对象是浏览器或者框架自身.top总是浏览器,parent是父框架,self表示自己.
window通常可以省略.
窗口操作: moveBy(dx, dy), moveTo(x, y),
resizeBy(dw, dh), resizeTo(w, h).
导航: window.open(url, frame
name, attribute). attribute可以是left, top, height, width, resizable,
scrollable, too ......
<iframe width='100%' height='100%' name='boot' id='boot' src='' frameborder='0' scrolling='no'></iframe>
<SCRIPT LANGUAGE="JavaScript">
<!--
var iframe = window.frames['boot'];
iframe.document.open();
iframe.document.write('<!DOCTY ......