最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to send javascript object from one page to another page? - Stack Overflow

programmeradmin4浏览0评论

Assume i have javascript object called "call" and i have stored some values in it and i want to access the same object "call" not values. This type of approach is it possible?

If yes plese explain with simple example.

I know there are several ways we can send the object properties values from one page to another page by using post url, header, cookies so on but my requirment to access the whole object instanse form one page to another page.

Anything in this regard highly appreciated. Thanks in advance.

Assume i have javascript object called "call" and i have stored some values in it and i want to access the same object "call" not values. This type of approach is it possible?

If yes plese explain with simple example.

I know there are several ways we can send the object properties values from one page to another page by using post url, header, cookies so on but my requirment to access the whole object instanse form one page to another page.

Anything in this regard highly appreciated. Thanks in advance.

Share Improve this question asked Jan 31, 2014 at 6:45 GirishGirish 1073 silver badges10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Just in addition to @gulshanm01's answer to store and retrieve an object you can use JSON.parse() and JSON.stringify() to parse the stored object.

E.g:

var obj = {
    fruit: "banana",
    fruit2: "apple",
    fruit3: "orange"
};
//Store
localStorage.setItem("obj", JSON.stringify(obj));
//Then retrieve
var localObj = JSON.parse(localStorage.getItem(obj));
alert(localObj.fruit);

you can use localStorage.setItem(key,value) and fetch the value on another page using localStorage.getItem(key)

发布评论

评论列表(0)

  1. 暂无评论