把Javascript对象序列化后作为参数传输

导入js文件:https://files.cnblogs.com/yangyh/json2.js

function Person(name,age,birthday){
this.Name = name;
this.Age = age;
this.Birthday = birthday;
}

var p = new Person("test测123",20,new Date());

var output = JSON.stringify(p);
var url = '('+output+')';
alert(output);
var outP = eval('('+output+')');
e = encodeURIComponent(output)
alert(e);
document.write('Name:'+outP.Name+'<br />')
document.write('Age'+outP.Age+'<br />')
document.write('Birthday'+outP.Birthday)
window.location.href = "t1.html?p="+url;



t1.html:

t=decodeURIComponent(getUrlPara('p'));
 alert(eval(t).Name);


 

 

posted on 2010-12-22 21:12  yangyh  阅读(990)  评论(0编辑  收藏  举报