Javascript 对象的比较
这个随笔其实是为了感谢清风笑给的一个提示,不仅仅是告诉我怎么判断数组,更让我有了认真读一读 《javascript权威指南》的想法。
比较和拷贝其实是一回事,代码如下:
//
//Compare object function
//
function Compare(fobj,sobj)
{
var ftype = typeof(fobj);
var stype = typeof(sobj);
if (ftype == stype)
{
if (ftype == "object")
{
if (fobj.constructor == Array && sobj.constructor == Array)//array
{
return CompareArray(fobj,sobj)
}
else if (fobj.constructor != Array && sobj.constructor != Array)//object
{
return CompareObject(fobj,sobj);
}
return false;
}
return fobj == sobj;
}
return false;
}
function CompareObject(fobj,sobj)
{
相关文档:
//Textarea maxlength
//flag:text框名字,num:限制的字节数
function maxLen(flag,num){
if(document.getElementById('lastMessage').value=="0" || document.getElementById('lastMessage').value==flag){
var i=document.getElementById(flag).value.replace(/[\u0 ......
<script>
//写cookies函数 作者:翟振凯
function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
......
第一种:
+展开
-HTML
<html>
<head>
</head>
<body>
<form name="form1">
<input type="text" name="getinfo" value="http://www.shuwo.net" size="40"><button onclick="alert(document.form1.getinfo.value ......
Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing valida ......
从2004年下半年开始学习Web编程至今3年有余。从HTML,asp开始到现在的VS2008一路学过来,其中学的最多的还是服务器端编程,对客户端编程的学习还是不成系统。虽然在很多个系统里面应用过脚本,有些还起到了比较重要的作用。但一直是只知其然不知其所以然,用的是小心翼翼。现在脚本编程从以前的"雕虫小技"变成了一个Web开 ......