[英]Alert for mobile users to switch to desktop should show only once but keeps repeating
我正在尝试提醒我的 Web 应用程序的用户切换到桌面以获得最佳体验。 警告框应该只出现一次,但到目前为止,它会随着页面的每次刷新或重新加载而不断弹出。
<script language="Javascript">
window.onload=function(){
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|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>
任何提示要召回的项目缺少什么?
谢谢
亚历克斯
试试这个
<script language="Javascript">
window.onload=function(){
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|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 {
...
}}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.