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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog