Get value of a variable in another page using jquery

拈花ヽ惹草 提交于 2019-12-06 08:40:41
viyancs

you can use localStorage() function, localstorage will be save your data like cookie, but it's very powefull because localstorage can be save data more big than cookie.

in your case maybe like this

$(document).ready(function() {
    $('input:button').click(function() {
        localStorage.setItem("text",$(this).val());
        });
}); 

and then in another page you just notify with this

$(function(){
 alert("text" + localStorage.getItem("text"));
});

this is for details local storage

Including the same Javascript file in two separate HTML pages will not carry over variable values over to each other. So it doesn't mean that since your common.js is in both files, you can access something modified in one page on the other.

You may want to use cookies, or a query string, or do some server-side code magic instead.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!