码迷,mamicode.com
首页 > Web开发 > 详细

网页顶端显示消息

时间:2014-10-16 14:00:22      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   os   ar   for   sp   div   on   

var cookiename=getCookie("screentopdiv");
if (cookiename == "0") {
document.write(‘<div id="screentopdiv" style=" text-align: center; font-size: 14px; padding: 5px 0; background-color: rgb(232, 72, 72); color: white;">Dear Customers, your order may will be delayed 1-3 days due to the strict inspections by customs in HK. <span style="float:right;margin-right: 5px;">&nbsp;</span> <span onclick="closetopdiv()" style="float:right;cursor: pointer;-webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);">+</span></div>‘);
}
else {
if(document.getElementById("screentopdiv"))
document.getElementById(‘screentopdiv‘).style.display = "none";
}
function closetopdiv() {
document.getElementById(‘screentopdiv‘).style.display = "none";
addCookie("screentopdiv", "1", 0);
}
function addCookie(objName,objValue,objHours){//添加cookie
var str = objName + "=" + escape(objValue);
if(objHours > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失
var date = new Date();
var ms = objHours*3600*1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
}
document.cookie = str;
}
function getCookie(objName){//获取指定名称的cookie的值
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName)
return unescape(temp[1]);
}
return "0";
}
function delCookie(name){//为了删除指定名称的cookie,可以将其过期时间设定为一个过去的时间
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=a; expires=" + date.toGMTString();
}

网页顶端显示消息

标签:style   color   io   os   ar   for   sp   div   on   

原文地址:http://www.cnblogs.com/kingreatwill/p/4028366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!