将cookie设置为与弹出窗口集成
Set cookies in intergrated with pop up
我的网站现在在主页中运行javascript弹出窗口,现在我想做的是当用户点击主页时,用户会进入主页,javascript弹出窗口会显示,但在点击关闭后,当用户再次点击主页时这个javascript不会运行,这个脚本只活动一天。
那么,如何将cookie与我的javascript弹出窗口集成?
*这个弹出窗口运行得很完美,但只留下cookie脚本
urlhttp://tsubamecorp.com/home/index.php?route=extras/blog/getblogcategory&blogpath=41
这是我的javascript弹出窗口:
<script>
var $xx = jQuery.noConflict();
$xx(document).ready(function() {
//select all the a tag with name equal to modal
$xx('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $xx(this).attr('href');
//Get the screen height and width
var maskHeight = $xx(document).height();
var maskWidth = $xx(window).width();
//Set heigth and width to mask to fill up the whole screen
$xx('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$xx('#mask').fadeIn(1000);
$xx('#mask').fadeTo("slow",0.90);
//Get the window height and width
var winH = $xx(window).height();
var winW = $xx(window).width();
//Set the popup window to center
$xx(id).css('top', winH/2-$xx(id).height()/1);
$xx(id).css('left', winW/2-$xx(id).width()/2);
//transition effect
$xx(id).fadeIn(1000);
});
//if close button is clicked
$xx('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$xx('#mask').hide();
$xx('.window').hide();
});
});
</script>
<script type="text/javascript">
window.onload = function() { $xx('a[href="#dialog1"]:eq(0)').click();
}
</script>
类似的内容。cookie的过期意味着在该时间之后cookie将被sys删除。谷歌一些文档.cookie
Cookie = {
get:function ( key ) {
var ret = this.toObj()[key];
if( ret === undefined ){
return ret;
}
return unescape ( this.toObj()[key] );
},
set:function ( key, value, expires ) {
if ( expires ){
var exdata = new Date();
exdata = exdata.setDate ( exdata.setDate() + expires ).toGMTString();
}
document.cookie = key+"="+escape(value) + ( exdata ? "; expires= " + exdata : "");
},
remove:function ( key ) {
document.cookie = key+"=remove;expires="+(new Date).toGMTString();
},
toJSON:function ( ) {
return JSON.stringify( this.toObj );
},
toObj:function ( ) {
var ret={}, cookiearr = document.cookie.split(";");
var i, start, key, value;
for ( i = 0; l = cookiearr[ i++ ];) {
start = l.indexOf ("=");
ret [ l.slice(0, start) ] = l.slice (start+1);
}
return ret;
}
}
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 防止Iframe窗体在新窗口中打开
- 内部分区字体大小获胜'调整浏览器窗口大小时不会随媒体查询而更改
- 调整窗口大小时,可拖动的对象会出现在容器外部
- Javascript排序的图像弹出窗口..可以't单独弹出
- 窗口大小html css
- 弹出窗口出现,然后退出
- 如何检测用于WebGL的专用或集成显卡
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- Javascript更新孙窗口中的表单元素
- 如何在选项卡上定义属性'的主窗口对象
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- 召回窗口加载事件 - javascript
- 为什么不显示警报窗口
- 如何使用modalDialog来显示可以在所有浏览器中工作的弹出窗口
- Chrome应用程序调整窗口大小保持纵横比
- 新选项卡被弹出窗口阻止程序阻止
- 如何访问UIWebView'的子窗口上下文
- 将cookie设置为与弹出窗口集成
- 集成谷歌地图w/ WordPress -信息窗口未打开