你可以使用
Javascript来完成它,你可以传递哪种对象没有限制.
例如,如果您有多个键值对象:
var firstData = {
'key1' : 'value1',
'key2' : 'value2'
};
和
var secondData = {
'key1' : 'value3',
'key2' : 'value4'
};
你可以使用Javascript数组将它们括起来:
// This is on page1.html
var myData = [ firstData, secondData ];
并使用localStorage传递该数组.
page1.html上的Javascript
// Set the variable
localStorage.setItem( 'objectToPass', myData );
第2页上的Javascript
// Get the variable
var myData = localStorage['objectToPass'];
localStorage.removeItem( 'objectToPass' ); // Clear the localStorage
var firstData = myData[0];
var secondData = myData[1];
alert('firstData: ' + firstData + '\nsecondData: ' + secondData);