特效描述:设置浏览器缓存 cookie提示 内容显示隐藏,jquery制作通过判断各种浏览器版本等,来设置各个浏览器缓存cookie,控制模块内容或区域在浏览器缓存cookie的情况下,是否显示或隐藏等操作。
代码结构
1. 引入JS
2. HTML代码
$(function(){
$('.WebDown .Close').click(function(){
$('.WebDown').fadeOut(300);
if($("#NotShow").attr("checked")){
setCookie("Browse","idea",30);
}
});
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
if(getCookie("Browse")=="idea"){
$('.WebDown').hide();
}else{
if(s){
$('.WebDown').fadeIn(200);
}
}
});
function getCookie( name ){
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+'='+escape( value ) +
( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
( ( path ) ? ';path=' + path : '' ) +
( ( domain ) ? ';domain=' + domain : '' ) +
( ( secure ) ? ';secure' : '' );
}
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
/* WebDown */
.WebDown{width:220px;border:solid 1px #ffbb76;margin:30px auto;}
.WebDown .tipbox{position:relative;height:50px;background:#fffcef;padding:10px;font-size:12px;}
.WebDown .laba,.WebDown .Close,.WebDown .arrow{background:url(images/tipboxbg.gif) no-repeat;}
.WebDown .laba{display:block;float:left;width:42px;height:39px;overflow:hidden;background-position:-27px 0;margin:5px 0 0 5px;}
.WebDown .tiptext{float:left;margin-left:15px;display:inline;}
.WebDown .tiptext h3{font-size:16px;color:#db7c22;font-family:"微软雅黑","宋体";height:34px;line-height:24px;}
.WebDown .tiptext p label{color:#999;cursor:pointer;margin-left:5px;}
.WebDown .Close{width:14px;height:14px;overflow:hidden;background-position:-13px 0px;position:absolute;bottom:10px;right:10px;cursor:pointer;}
.WebDown .arrow{display:block;width:13px;height:7px;overflow:hidden;background-position:0 -7px;position:absolute;left:15px;top:-7px;}
点击采集发布商品
以后不再显示