Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript - How do I open a new page and pass JSON data to it?

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?

like image 245
James Avatar asked Dec 06 '12 00:12

James


2 Answers

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

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).

like image 82
Ulflander Avatar answered Oct 13 '22 10:10

Ulflander


Assuming the two pages are on the same domain, you can use the returned object created by window.open() to access (and edit) the window object of a newly opened window.

like image 24
Sophie Avatar answered Oct 13 '22 10:10

Sophie