我正试图提醒web应用程序的用户切换到桌面以获得最佳体验。警报框应该只出现一次,但到目前为止,每次刷新或重新加载页面时,它都会不断弹出。
<script language="Javascript">
window.onload=function(){
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windowssce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
var alerted = localStorage.getItem('alerted') || '';
if (alerted != 'yes') {
alert("Visit this on a Computer for Better View");
localStorage.setItem('alerted','yes');
} else {
}}}
</script>
有什么提示需要召回的物品缺少什么吗?
感谢
Alex
试试这个
<script language="Javascript">
window.onload=function(){
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windowssce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
var alerted = localStorage.getItem('alerted') || false;
if (alerted !== true) {
alert("Visit this on a Computer for Better View");
localStorage.setItem('alerted', true);
} else {
...
}}}