JavaScript-如何打开新页面并将JSON数据传递给它? [英] JavaScript - How do I open a new page and pass JSON data to it?

查看:253
本文介绍了JavaScript-如何打开新页面并将JSON数据传递给它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为search.jsp的页面.当用户选择一条记录并按下编辑按钮时,我想用记录数据(存储在json对象中并传递到新页面)打开一个新页面(在同一窗口中).如何使用Javascript(或jQuery)打开新页面并传递JSON数据?

I have a page called search.jsp. When the user selects a record and the presses an edit button, I would like to open a new page (in the same window) with the record data (that is stored in a json object and passed to the new page). How do I use Javascript (or jQuery) to open a new page and pass the JSON data?

推荐答案

如果两个页面位于同一域中,则第三种方法是使用HTML5 localStorage:

If the two pages are on the same domain, a third way is to use HTML5 localStorage: http://diveintohtml5.info/storage.html

实际上,localStorage恰好适合您想要的内容.处理GET参数或窗口/文档JS引用不是很可移植(即使我知道所有浏览器都不支持localStorage).

In fact localStorage is precisely intended for what you want. Dealing with GET params or window/document JS references is not very portable (even if, I know, all browsers do not support localStorage).

这篇关于JavaScript-如何打开新页面并将JSON数据传递给它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆