Created
December 31, 2019 05:00
-
-
Save samarulrajt/c88d0ef73398793af0093d2eb7a70a4c to your computer and use it in GitHub Desktop.
Verify if PRIVATE BROWSING is blocking local storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ERROR FOR BLOCKED LOCAL STORAGE --> | |
<div id="apple_storage" style="display:none;"> | |
<div class="modal-new alerts"> | |
<h2>Attenion</h2> | |
<a href="" class="close" onclick="document.getElementById('apple_storage').style.display = 'none';">Close</a> | |
<div class="body"> | |
<p> | |
Dear customer, to ensure proper use of the site it is necessary to abandon the | |
private browsing. | |
</p> | |
</div><!-- /.body --> | |
</div> | |
</div> | |
<!-- ERROR FOR BLOCKED COOKIES --> | |
<div id="no_cookie" style="display:none;"> | |
<div class="modal-new alerts"> | |
<h2>Attenion</h2> | |
<a href="" class="close" onclick="document.getElementById('no_cookie').style.display = 'none';">Close</a> | |
<div class="body"> | |
<p> | |
Dear customer, to ensure proper use of the site it is necessary to enable cookies. | |
</p> | |
</div><!-- /.body --> | |
</div> | |
</div> | |
<!-- Verify if PRIVATE BROWSING is blocking local storage --> | |
<script> | |
var hasStorage = function() { | |
var mod, | |
result; | |
try { | |
mod = new Date; | |
localStorage.setItem(mod, mod.toString()); | |
result = localStorage.getItem(mod) === mod.toString(); | |
localStorage.removeItem(mod); | |
return result; | |
} catch (_error) { | |
return false; | |
} | |
}, | |
hasCookies = function() { | |
var cookieEnabled = navigator.cookieEnabled ? true : false; | |
if (typeof navigator.cookieEnabled == 'undefined' && !cookieEnabled) { | |
document.cookie = 'testcookie'; | |
cookieEnabled = (document.cookie.indexOf('testcookie') != -1) ? true : false; | |
} | |
return cookieEnabled; | |
}; | |
if (!hasStorage()) { | |
document.getElementById('apple_storage').style.display = 'block'; | |
} else if (!hasCookies()) { | |
document.getElementById('no_cookie').style.display = 'block'; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment