Вы можете использовать печенье, window.name
, отправьте данные по URL-адресу в качестве запроса или через web storage.
В этом exaple я собираюсь сохранить данные из одной страницы и читать его с другой страницы с помощью localStorage - specs(), и следующие методы:
логин.HTML
function saveData(user, pass) {
var account = {
User: user,
Pass: pass
};
//converts to JSON string the Object
account = JSON.stringify(account);
//creates a base-64 encoded ASCII string
account = btoa(account);
//save the encoded accout to web storage
localStorage.setItem('_account', account);
}
index.html
function loadData() {
var account = localStorage.getItem('_account');
if (!account) return false;
localStorage.removeItem('_account');
//decodes a string data encoded using base-64
account = atob(account);
//parses to Object the JSON string
account = JSON.parse(account);
//do what you need with the Object
fillFields(account.User, account.Pass);
return true;
}
Передача объекта от одной страницы к другой URL, как QueryString(поиск)
login.html
function saveData(user, pass) {
var account = {
User: user,
Pass: pass
};
account = JSON.stringify(account);
account = btoa(account);
location.assign("index.html?a=" + account);
}
index.html
function loadData() {
var account = location.search;
if (!account) return false;
account = account.substr(1);
//gets the 'a' parameter from querystring
var a = (/^a=/);
account = account.split("&").filter(function(item) {
return a.test(item);
});
if (!account.length) return false;
//gets the first element 'a' matched
account = account[0].replace("a=", "");
account = atob(account);
account = JSON.parse(account);
//do what you need with the Object
fillFields(account.User, account.Pass);
return true;
}
Смотрите расширенный ответ здесь: https://stackoverflow.com/a/30070207/2247494
Отъезд [это] (http://stackoverflow.com/q/11581543/778118). Кроме того, на эту тему имеется много информации. Вы должны включить свой Google. – jahroy
«_Questions должны продемонстрировать минимальное понимание проблемы, которая будет решена. Расскажите, что вы пытались сделать, почему это не сработало и как это должно работать.» «Голосование, чтобы закрыть. – jahroy
Окрашенный дубликат: * – Jack