After a good few hours trying to debug a web app in Mobile Safari here at kc web design kent we finally worked out that having private browsing turned on in the Safari settings was causing javascript and local storage to not work. Safari mobile seems to deal with private browsing differently to other browsers and it actually stops any kind of local storage from being set where as Chrome still allows a certain amount of storage to be accessed.
To warn users that they have private browsing on we can do a little check with javascript…
var testKey = 'qeTest', storage = window.sessionStorage; try { // Try and catch quota exceeded errors storage.setItem(testKey, '1'); storage.removeItem(testKey); } catch (error) { if (error.code === DOMException.QUOTA_EXCEEDED_ERR && storage.length === 0) alert('Please make sure you have private browsing turned off in your Safari settings to use this website'); else throw error; }
This will check whether local storage can be set and if not warn the user that they have private browsing turned on. Hopefully this will help anyone else that comes up against this problem.
Why Effective Design is Crucial for Kent Businesses In today’s competitive market, effective design plays a pivotal role in shaping brand identity and fostering trust. A well-crafted visual identity can set a business apart…
Paid for your website but don't hold the domain, hosting or admin login? Here's how Kent small businesses can check who owns their website and take control back.
How Kent businesses can build location pages that rank in Canterbury, Whitstable and Herne Bay searches - structure, content and mistakes to avoid.
Your cookie preferences
With your permission, Google Analytics helps me understand which pages are useful and how visitors get in touch. You can use this site without analytics and change your choice at any time.