Reputation: 3
Problem :- Prevent website from running a particular piece of script on page(A) refresh. The script shouldn't run even if the user navigates to another page (B) and comes back to page (A).
Solution prescribed :- Use HTML 5 session storage to keep track of number of times page is visited during an active session. If session variable doesn't exist, it means it's the first visit. If session variable exists, block the script.
Issue :- HTML5 session storage not supported in IE 7. Even if the browser used is IE 11, using meta content="IE=EmulateIE7" tag, the browser is forced to render like IE7.
Is usage of session storage my best option for the problem at hand? If yes, how do I resolve the IE7 issue?
Upvotes: 0
Views: 1496
Reputation: 4297
Sorry, you just can't, even with Store.js
No. I believe there is no way to provide sessionStorage semantics cross browser.
Upvotes: 0
Reputation: 34489
Take a look at using Store.js, it's a simple wrapper around session that will fallback to userData in IE6 and IE7. This gives you consistency in your code and abstracts the complexities of switching between the two mechanisms for you.
store.js uses localStorage when available, and falls back on the userData behavior in IE6 and IE7. No flash to slow down your page load. No cookies to fatten your network requests.
Upvotes: 1