qq_18879217 2015-05-05 03:40 采纳率: 0%
浏览 2083

我想让我的网站右下角的视频弹窗24小时同一个ip只显示一次,JavaScript

我想让我的网站右下角的视频弹窗24小时同一个ip只显示一次,谁能帮我看看代码,我不懂

function miaovAddEvent(oEle, sEventName, fnHandler)
{
    if(oEle.attachEvent)
    {
        oEle.attachEvent('on'+sEventName, fnHandler);
    }
    else
    {
        oEle.addEventListener(sEventName, fnHandler, false);
    }
}

window.onload = function() {
    var oDiv = document.getElementById('miaov_float_layer');
    var oBtnMin = document.getElementById('btn_min');
    var oBtnClose = document.getElementById('btn_close');
    var oDivContent = oDiv.getElementsByTagName('div')[0];

    var iMaxHeight = 0;

    var isIE6 = window.navigator.userAgent.match(/MSIE 6/ig) && !window.navigator.userAgent.match(/MSIE 7|8/ig);

    oDiv.style.display = 'block';
    iMaxHeight = oDivContent.offsetHeight;

    if (isIE6) {
        oDiv.style.position = 'absolute';
        repositionAbsolute();
        miaovAddEvent(window, 'scroll', repositionAbsolute);
        miaovAddEvent(window, 'resize', repositionAbsolute);
    }
    else {
        oDiv.style.position = 'fixed';
        repositionFixed();
        miaovAddEvent(window, 'resize', repositionFixed);
    }

    oBtnMin.timer = null;
    oBtnMin.isMax = true;
    oBtnMin.onclick = function() {
        startMove
        (
            oDivContent, (this.isMax = !this.isMax) ? iMaxHeight : 0,
            function() {
                oBtnMin.className = oBtnMin.className == 'min' ? 'max' : 'min';
            }
        );
    };

    oBtnClose.onclick = function() {
        oDiv.style.display = 'none';
        oDiv.innerHTML = "";
    };
};

function startMove(obj, iTarget, fnCallBackEnd)
{
    if(obj.timer)
    {
        clearInterval(obj.timer);
    }
    obj.timer=setInterval
    (
        function ()
        {
            doMove(obj, iTarget, fnCallBackEnd);
        },30
    );
}

function doMove(obj, iTarget, fnCallBackEnd)
{
    var iSpeed=(iTarget-obj.offsetHeight)/8;

    if(obj.offsetHeight==iTarget)
    {
        clearInterval(obj.timer);
        obj.timer=null;
        if(fnCallBackEnd)
        {
            fnCallBackEnd();
        }
    }
    else
    {
        iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
        obj.style.height=obj.offsetHeight+iSpeed+'px';

        ((window.navigator.userAgent.match(/MSIE 6/ig) && window.navigator.userAgent.match(/MSIE 6/ig).length==2)?repositionAbsolute:repositionFixed)()
    }
}

function repositionAbsolute()
{
    var oDiv=document.getElementById('miaov_float_layer');
    var left=document.body.scrollLeft||document.documentElement.scrollLeft;
    var top=document.body.scrollTop||document.documentElement.scrollTop;
    var width=document.documentElement.clientWidth;
    var height=document.documentElement.clientHeight;

    oDiv.style.left=left+width-oDiv.offsetWidth+'px';
    oDiv.style.top=top+height-oDiv.offsetHeight+'px';
}

function repositionFixed()
{
    var oDiv=document.getElementById('miaov_float_layer');
    var width=document.documentElement.clientWidth;
    var height=document.documentElement.clientHeight;

    oDiv.style.left=width-oDiv.offsetWidth+'px';
    oDiv.style.top=height-oDiv.offsetHeight+'px';
}


  • 写回答

3条回答 默认 最新

  • threenewbee 2015-05-05 03:48
    关注

    最简单的是用cookie,设置一天过期。服务器判断,有这个cookie就不发弹窗,否则就发。

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序