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;
}
}
相关文档:
引自:http://www.cnblogs.com/dongritengfei/archive/2009/12/21/1628489.html
今天弄了一天的Ajax中文乱码问题,Ajax的乱码问题分为两种:
1. JavaScript输出的中文乱码,
比如:alert("中文乱码测试");
解决的办法比较简单,就是把jsp里所有的charset和pageEncoding的值都设置成相同的,一般是utf-8.
  ......
//设置当前页面为用户的首页
function setHomepage()
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(window.location.href);
event.returnValue=false;
return;
}
//加入收藏
function addFavorite()
{
&nb ......
<input type=button onclick="aaa();" value="确定">
<iframe name="frame1">
<script language=javascript>
function aaa()
{
docume ......
javascript中innerHtml用法
2009-04-21 22:52
<html>
<head>
<script language="javascript">
function Test(){
var str="";
str+="Hello,";
str+="This ......
源码:
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 ......