I am trying to retrieve data from another page by using sessionstorage.
My first page home.html
function go_to_faq(qnum){
window.open('FAQ.html', '_blank');
sessionStorage.setItem('key2', qnum);
}
<a style="cursor: pointer;" onclick="go_to_faq('1')" target="_blank"> Open First Question </a>
<a style="cursor: pointer;" onclick="go_to_faq('2')" target="_blank"> Open Last Question</a>
Second page FAQ.html
var qpara2 = sessionStorage.getItem('key2');
alert(qpara2);
First issue:
At first click on (Open First Question), it give me null. Second click gives me the right value(1).
If I click the second link (Open Last Question), it gives me the last old value (1). When I click it again it will update it and give me (2). So it does not work properly from the first click.
Second issue:
It does not work in IE.
first issue is fixed .. I have just to open the page after store the value
function go_to_faq(qnum){
sessionStorage.setItem('key2', qnum);
window.open('FAQ.html', '_blank');
}
If it doesn't work in IE which I am assuming refers to the Internet Explorer then you can try using some other browser like Firefox, Google Chrome, Microsoft Edge. Also, I would recommend using Firefox.
you need to open the page (window.open) and then apply your changes on there !