想让他只弹出一次,就不在弹了,请问各位大神如何改
//top_wechat
(function(){
var sHTML = [
'<style type="text/css">',
'.topTips { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: fixed; left:0; top: 0; width: 100%; z-index: 1000000000;-webkit-perspective: 600px; perspective: 600px; }',
'.tipsInner {font-family: "Microsoft YaHei"; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); background: #f3f3f3;-webkit-transform-origin: 0px 0px; transform-origin: 0px 0px; -webkit-transform: rotateX(90deg); transform: rotateX(90deg); opacity: 0; }',
'.tipsInner a { text-decoration:none;display: block; position: relative; padding-left: 50px; color: #111; }',
'.tipsInner img { position: absolute; left: 8px; top: 50%; margin-top: -17px; width: 36px; height: auto; padding-right: 5px; background:#f3f3f3; }',
'.tipsInner dl { margin:0; padding: 10px 5px; border-left: 1px solid #ccc; }',
'.tipsInner dt { font-weight: bold;line-height:1em; color:#333; }',
'.tipsInner dd { margin:0; line-height: 1.2em;white-space:nowrap;text-overflow:ellipsis;overflow:hidden; color:#666; }',
'.showTip { visibility:visible; }',
'.showTip .tipsInner { -webkit-transform-origin: 0px 0px; transform-origin: 0px 0px; -webkit-transform: rotateX(0deg); transform: rotateX(0deg); opacity: 1; }',
'.hideTip { visibility:hidden; }',
'.hideTip .tipsInner { -webkit-transform-origin: 0px 100%; transform-origin: 0px 100%; -webkit-transform: rotateX(-90deg); transform: rotateX(-90deg); opacity: 0; }',
'</style>',
'<div class="topTips" id="toptips">',
' <div class="tipsInner">',
' <a onclick="openZoosUrl();return false;" href="javascript:void(0);return false;" class="JS-SWT-LINK" >',
' <img src="/images/qqIcon.png" alt="">',
' <dl>',
' <dt>于专家:</dt>',
' <dd>我是在线专家,请问有什么可以帮您?……</dd>',
' </dl>',
' </a>',
' </div>',
'</div>'].join('\r\n');
var o = document.createElement('div');
o.innerHTML = sHTML;
while(o.firstElementChild){
document.body.appendChild(o.firstElementChild);
};
T={hasClass:function(d,a){var c=d.className.split(/\s+/);for(var b=0;b<c.length;b++){if(c[b]==a){return true}}return false},addClass:function(b,a){if(!this.hasClass(b,a)){b.className+=" "+a}},removeClass:function(d,a){if(this.hasClass(d,a)){var c=d.className.split(/\s+/);for(var b=0;b<c.length;b++){if(c[b]==a){delete c[b]}}d.className=c.join(" ")}}};
function Toptips(options){
this.init(options);
};
Toptips.prototype = {
constructor : Toptips,
init : function(options){
this.item = options.item;
this.itemInner = options.item.children[0];
this.loop = typeof options.loop == "undefined" ? true : options.loop;
this.showTime = typeof options.showTime == "undefined" ? 5000 : options.showTime;
this.hideTime = typeof options.hideTime == "undefined" ? 15000 : options.hideTime;
this.showTimer = null;
this.hideTimer = null;
this.preTimer = null;
this.item.style.WebkitTransition = this.item.style.transition = this.itemInner.style.WebkitTransition = this.itemInner.style.transition = "0.5s";
var me = this;
var initTimer = setTimeout(function(){
me.showTip();
},9000);
},
showTip : function(){
var me = this;
T.addClass(me.item,"showTip");
T.removeClass(me.item,"hideTip");
clearTimeout(me.hideTimer);
me.showTimer = setTimeout(function(){
me.hideTip();
},me.showTime);
},
hideTip : function(){
var me = this;
T.removeClass(me.item,"showTip");
T.addClass(me.item,"hideTip");
me.item.style.visibility = me.itemInner.style.visibility = "hidden";
if(me.loop){
clearTimeout(me.showTimer);
me.preTimer = setTimeout(function(){
me.item.style.visibility = me.itemInner.style.visibility = "visible";
},me.hideTime-100);
me.hideTimer = setTimeout(function(){
me.showTip();
},me.hideTime);
}
},
};
setTimeout(function(){
var toptip = document.getElementById("toptips");
new Toptips({
item : toptip,
loop : true
});
},9000);
return false;
delete o;
})();
代码里用了一个loop来标记是否循环弹出
this.loop = typeof options.loop == "undefined" ? true : options.loop; //init
if(me.loop) //hideTip
实例化时,让loop为false,那么就不执行循环,每次打开只加载一次
new Toptips({