Home > OS >  issue with session storage
issue with session storage

Time:11-07

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>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

Second page FAQ.html

var qpara2 = sessionStorage.getItem('key2');

alert(qpara2);
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

first issue:

at first click on (Open First Question) ,it give me null .. second click give me the right value(1)

and if I click the second link (Open Last Question) ,it give me the last old value (1) .. and when I click it again it will update it and give me (2)

so it does not work properly from the first click

my second issue:

it does not work in IE :(

any suggestion please

thanks

CodePudding user response:

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');



}
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

please help me fixed the issue with IE

CodePudding user response:

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.

  • Related