javascript - 我只想向 Internet Explorer (10 -11) 显示一条消息并每天显示一次
问题描述
我只想向 Internet Explorer (10 -11) 显示一条消息并每天显示一次
if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
{
$(window).on('load', function () {
if (!Cookies.get('alreadyShow')) {
Cookies.set('alreadyShow', true, {
expires: 1
});
$('#ie-note-1').addClass('show');
}
});
}
由于 cookie 脚本,消息未显示,可能无法与 IE 一起使用,或者出现了一些混乱
它总是显示“Cookies”未定义,但我正在添加
<script src="http://lab.alexcican.com/set_cookies/cookie.js"></script>
解决方案
您可以使用 localStorage 来存储变量并检查它今天是否显示。
var day = new Date().getDate();
var val = localStorage.getItem("cur_date");
if (!val || val != day) {
// Show message and update cur_date
localStorage.setItem("cur_date", day);
}
推荐阅读
- javascript - 离开页面前的对话框动作
- vb.net - 如何用函数做一个方法?
- javascript - 当我不希望它时,Visual Code 自动格式会放置新行
- sql - Teradata SQL - CREATE table as select - 表填充的结果集与手动运行查询不同
- angular6 - 如何在 ngOnInit 获得 localstorage 的值
- python - Python随机生成每个实例的种子
- arrays - 在 Matlab 中使用匿名 fnc 时如何将值存储到数组中以绘制它们
- game-maker - GameMaker Studio 2 - 中心 + 钳位相机变焦
- tensorflow - 从 tfrecords 中的不平衡数据生成平衡批次
- php - 如何在 html 和 php 中制作 PIVOT(Crosstab)