First Page
<button onclick="refereceid_Transfer()">Try it</button>
<script>
function refereceid_Transfer() {
alert('test');
var referenceid = "jggd154278";
referenceid = btoa(referenceid);
//sessionStorage.setItem("sent", referenceid);
window.open("second.jsp", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
}
</script>
Second Page
<p id="s1"></p>
<script>
$(document).ready(function(){
// var a = sessionStorage.getItem("sent",id);
alert(a);
});
</script>
I need to pass my reference id from one window to another window. I tried use session storage and local storage to pass variable and i have failed in both condition. is there new suggestion that i can pass my reference id to new window.
Thanks
First Page
<button onclick="refereceid_Transfer()">Try it</button>
<script>
function refereceid_Transfer() {
alert('test');
var referenceid = "jggd154278";
referenceid = btoa(referenceid);
//sessionStorage.setItem("sent", referenceid);
window.open("second.jsp", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
}
</script>
Second Page
<p id="s1"></p>
<script>
$(document).ready(function(){
// var a = sessionStorage.getItem("sent",id);
alert(a);
});
</script>
I need to pass my reference id from one window to another window. I tried use session storage and local storage to pass variable and i have failed in both condition. is there new suggestion that i can pass my reference id to new window.
Thanks
Share Improve this question asked Sep 11, 2017 at 3:29 kuhandran samudra pandiyankuhandran samudra pandiyan 731 gold badge2 silver badges9 bronze badges2 Answers
Reset to default 4You can try localStorage for this.
Add item which you want to pass on another page:
localStorage.setItem("key", "value");
On another page you can access through:
localStorage.getItem("key");
You can store object data as well in localStorage. Note that clear localStorage if you're storing some sensitive information.
And simpler option is to use query parameter, but I think you're not okay with it.
Or you can use sessionStorage:
sessionStorage.setItem("key", data);
window.open("page_url","_blank");
on another page use:
$(document).ready(function(){
var data = sessionStorage.getItem("key");
console.dir(data);
});
Note: The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the specific browser tab.
You can do it with local storage or you can pass it in query parameters and read the query parameters at 2nd page. If you are doing server side rendering you can also use session storage.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744275984a4566332.html
评论列表(0条)