Session storage does not work in IE

I use the following code to check for HTML 5 session storage. It works fine in all browsers except IE. IE version 10 installed.

Code:

<!DOCTYPE html> <html> <head> <script> function clickCounter() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickcount) { sessionStorage.clickcount=Number(sessionStorage.clickcount)+1; } else { sessionStorage.clickcount=1; } document.getElementById("result").innerHTML="You have clicked the button " + sessionStorage.clickcount + " time(s) in this session."; } else { document.getElementById("result").innerHTML="Sorry, your browser does not support web storage..."; } } </script> </head> <body> <p><button onclick="clickCounter()" type="button">Click me!</button></p> <div id="result"></div> <p>Click the button to see the counter increase.</p> <p>Close the browser tab (or window), and try again, and the counter is reset.</p> </body> </html> 

What could be the problem?

+6
source share
1 answer

What I found with both local repositories and HTML5 session storage functions is that both of these functions will work in Internet Explorer ONLY when the page is displayed via HTTP and will not work when you try to access this in the local file system i.e. you are trying to open a sample webpage directly from the file system with the sort URL, C:/Users/Mitaksh/Desktop , etc.

Deploy the application through any application server , such as Tomcat , etc., and then run it .. and you can see both local and session storage in action, then ..

+17
source

Source: https://habr.com/ru/post/943610/


All Articles