js实现弹出的提示框只弹出一次

时间:2024-01-14 10:51:02
 <script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
//alert("iphone");
} else if (/android/.test(ua)) {
var alertmessage="温馨提示:您可以在右下角的菜单中下载最新版本的手机版APP哦!\n \n本提示只出现一次!"
var once_per_session=1
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function alertornot(){
if (get_cookie('alerted')==''){
loadalert()
document.cookie="alerted=yes"
}
}
function loadalert(){
alert(alertmessage)
}
if (once_per_session==0)
loadalert()
else
alertornot()
}
</script>

其实就是记录cookie。