如何使模式窗口只显示一次
How do I make my modal window only show up once?
如何在脚本中添加cookie附件?我浏览了这个网站,试图放置代码,但都没有成功。
这是我的代码:
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
任何人都可以帮我添加一个cookie片段,这样窗口只打开一次/用户,那就太好了。
使用one()
:只能在click
上附加一次事件
$('a[name=modal]').one('click', function(){ ... });
相关文章:
- 一次显示一个隐藏指令-AngularJS
- 一次显示一个指令AngularJS
- Slding表单不会一次显示一个表单
- 一次显示/隐藏一个Javascript
- 一次显示一个标记-谷歌地图API v3
- 一次显示n个列表元素,jQuery
- 想要在fullcalendar插件的周视图中一次显示3天
- 用JavaScript制作战斗模拟器,无法一次显示整个模拟
- 尝试连续一次显示多个 php 文件
- 如何使用 javascript 一次显示此数组的字符串内容
- 如何保持一次显示一个悬停
- 引导轮播不起作用(一次显示所有图像)
- 在一个页面上一次显示所有“标题”工具提示
- 如何设置仅一次显示通知栏的cookie
- 从上到下的可见图像堆积:有没有办法一次显示
- 枚举内容滑块一次显示两个图像
- 使用 JS 随机化表行,同时一次显示一个表行
- 寻找一个JS滑块插件,它支持一次显示多张幻灯片,以及不同宽度的幻灯片
- 选择项目并一次显示n篇文章
- 一次显示一个DOM元素的淡入/淡出列表