我环顾四周,找不到确切的解决方案,但如果确实存在,我深表歉意。
现在,我遇到的问题是每个会话向旧版本 Internet Explorer 的用户显示一个 div,即 < IE9。
这是我快速整理的代码,但它似乎不起作用,有人可以告诉我它有什么问题吗?我做错了吗?
<!--[if lt IE 9]>
<script>
/* Set initial cookie after entire page has loaded */
document.cookie="messageseen=true";
/***********
This cookie won't exist initially, but when the if statement below checks
for the message seen cookie, the clear message cookie will also be set,
this is so on subsequent page-loads, it won't take 5 seconds for the the
message to disappear.
***********/
if (document.cookie == "clearmessage") {
$('.ie-message').hide(); // hide message without delate
}
/***********
After 5 seconds, check for the messageseen cookie, if it exists, set the
clearmessage cookie and hide .ie-message. On all subsequent page-loads,
the message will be hidden immediately without the delay.
***********/
setTimeout(function (){
if (document.cookie == "messageseen") {
document.cookie="clearmessage=true";
$('.ie-message').hide(); // hide message if cookie is set
}
}, 5000); // delay the hiding of the message for 5 seconds
</script>
<![endif]-->