JavaScript 深度克隆 JSON 对象
function
clone(jsonObj) {
var
buf;
if
(jsonObj
instanceof
Array) {
buf = [];
var
i = jsonObj.length;
while
(i--) {
buf[i] = clone(jsonObj[i]);
}
return
buf;
}else
if
(jsonObj
instanceof
Object){
buf = {};
for
(
var
k
in
jsonObj) {
buf[k] = clone(jsonObj[k]);
}
return
buf;
}else
{
return
jsonObj;
}
}
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
/*
由于javascript是一种无类型语言,所以一个数组的元素可以具有任意的数据类型,同一个数组的不同元素
可以具有不同的类型,数组的元素设置可以包含其他数组,这样就可以创建一个复杂的数组了.
并且在这点上说javascript作为一种脚本语言不同于那种严格的面向对象的c++.c#,java了.具有更高的灵活性.
&n ......
//设置当前页面为用户的首页
function setHomepage()
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(window.location.href);
event.returnValue=false;
return;
}
//加入收藏
function addFavorite()
{
&nb ......
东西很简单,只是自己记性不好,经常忘记一些关键字
所以发了点时间整理了一下
/*------------------------------------------------------
*作者:xieyu @ 2007-08-14
*语言:JavaScript
*说明:select元素javascript常用操作
* 1.判断是否存在指定value的Item
* 2.加入一 ......
源码:
function resize(img, width, height) {
(img.width > img.height)
? ((img.height = Math.min(height, width * img.height/img.width)) || (img.width = Math.min(width, img.width)))
: ((img.width = Math.min(width, height * img.width/img.height)) || (img.height = Math.min(hei ......