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

导入js文件:http://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);





 



 

你可能感兴趣的:(JavaScript)