[英]Highslide Auto Popup For One Time
Sir / Madam, 主席/女士
I have used Highslide script for auto popup on an index page. 我使用Highslide脚本在索引页面上自动弹出。 So that when user open the website, a popup should get visible that having a custom message.
这样,当用户打开网站时,将弹出带有自定义消息的弹出窗口。 But I want that it should visible only for one time to the user, and if user close the popup it should not visible again till browser session is active.
但是我希望它只对用户可见一次,并且如果用户关闭弹出窗口,则在浏览器会话处于活动状态之前,它不应再次可见。 Auto popup code is working properly, but i want it to visible only for one time.
自动弹出代码正常工作,但我只希望它一次可见。
I have used the code below: (Below code should be between head tag) 我使用了下面的代码:(下面的代码应该在head标签之间)
<!---For HighSlide Auto Popup---> <script type="text/javascript" src="highslide/highslide-full.js"></script> <link rel="stylesheet" type="text/css" href="highslide/highslide.css"> <script type='text/javascript'>//<![CDATA[ // automatically open a link to a HTML page hs.graphicsDir = 'highslide/graphics/'; hs.align = 'center'; hs.outlineType = 'rounded-white'; hs.dimmingOpacity = 0.75; hs.addEventListener(window, "load", function() { // click the element virtually: document.getElementById("autoload").onclick(); }); hs.registerOverlay({ html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>', position: 'top right', fade: 2 // fading the semi-transparent overlay looks bad in IE }); //]]> </script> <!---Ends Here--->
HTML code: (below code should be after body open tag ) HTML代码:(以下代码应在body open标记之后 )
<a id="autoload" class="highslide" href="popup.html" onclick="return hs.htmlExpand(this, {objectType: 'iframe', wrapperClassName: 'draggable-header'})" style="display:none;"></a>
Hope you should do needful as soon as possible.... 希望您应该尽快做有需要的事情。
See this jsFiddle: http://jsfiddle.net/72uny6ba/ 看到这个jsFiddle: http : //jsfiddle.net/72uny6ba/
HTML code: HTML代码:
<a id="autoload" class="highslide" style="display: none;" href="https://fiddle.jshell.net/roadrash/7AHX9/show/light/" onclick="return hs.htmlExpand(this, {objectType: 'iframe', wrapperClassName: 'draggable-header'})">Autoloaded popup</a>
JavaScript for cookie and autoload: 用于cookie和自动加载的JavaScript:
// cookie
function bakecookie(name, value) {
var argv = bakecookie.arguments;
var argc = bakecookie.arguments.length;
var daysgood = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : "/";
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
var expires = new Date();
expires.setDate (expires.getDate()+daysgood);
document.cookie = name + "=" + escape (value) +((daysgood == null) ? "" : ("; expires=" + expires.toGMTString())) +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +((secure == true) ? "; secure" : "");
}
function eatcookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {return eatcookieval (j);}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) {break;}
}
return null;
}
function eatcookieval(offset){
var endstr=document.cookie.indexOf(";",offset);
if (endstr == -1) {endstr = document.cookie.length;}
return unescape(document.cookie.substring(offset,endstr));
}
// autoload popup
hs.addEventListener(window, "load", function () {
// click the element virtually:
if (!eatcookie('YouveSeenOurNewSite')) {
document.getElementById("autoload").onclick();
}
});
// set the cookie
hs.Expander.prototype.onAfterExpand = function (sender) {
bakecookie('YouveSeenOurNewSite', true, 365);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.