In Microsoft Edge, when I right click on a link and use "Open in new tab" option, then I can see/access sessionStorage values created in initial page. However, this issue is not there in Chrome and Firefox browsers. You can see this issue in this JSFiddle.
- Open JS Fiddle link (in Edge)
- Enter any text. Observe entered text is shown in output section text field item
- Right Click on "Run" button and choose "Open in new tab". Observe text entered in previous step in another browser tab is accessible in this new tab. As per documentation sessionStorage is created for each tab and it is private to the tab.
If you repeat these steps in Chrome or Firefox, you wont see this issue. Why does sessionStorage in Edge browser behaves differently from other browsers like Firefox and chrome? Is there any work around for this issue in Edge browser?
<span>Your Name is</span> <input type="text" id="name"/>
(function() {
// check value exists or not in session storage
if (sessionStorage.getItem("username") == null || sessionStorage.getItem("username") == undefined)
{
vUserName = prompt("Enter your name");
sessionStorage.setItem("username", vUserName);
}
document.getElementById("name").value = sessionStorage.getItem("username");
})();