一段时间后如何在现场访问时出现弹出窗口?

时间:2014-09-03 14:21:03

标签: javascript cookies popup timestamp

如何在访问者留在网站3分钟后显示弹出窗口,它可以是网站的任何页面。

我读过一篇文章来使用setTimeout(function(){},time); 我是JS的新手但每次添加Timeout都会破坏我的代码。

感谢您的帮助!!

我的代码在

下面
            <div id="popup_a" class="popup_ABA">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="center"><div>THANK YOU FOR YOUR HELP</div></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="46%" align="right"><a href="#" class="nothanks">No</a></td>
                <td width="8%" class="popUpFooter_ABA">&nbsp;</td>
                <td width="46%" align="left"><span class="popUpFooter_ABA"><a href="#" class="dosurvey" onClick="dosurvey('#', 'invitationwindow', 800, 550);">Yes</a></span></td>
              </tr>
            </table></td>
        </tr>
      </table>
    </div>
    <script type="text/javascript">
    $(document).ready( function() {

    $.cookie('cisit292014', '1', {expires: 15, path: '/'});

    setInterval(function() {

    if ($.cookie('cisit292014') == 11){
        if ($.cookie('01092014') != '1') { // Check for cookie
    $.cookie('01092014', '1', { expires: 30, path: '/' });             
    // TO Unload the Popupbox
    function unloadPopupBox(){$('#popup_a').fadeOut("slow");}   
    // To Load the Popupbox
    function loadPopupBox(){$('#popup_a').fadeIn("slow");}

    // When site loaded, load the Popupbox First
    loadPopupBox();
    $('.nothanks').click( function() {unloadPopupBox();});
    $('.dosurvey').click( function() {unloadPopupBox();});

    }
    }       

    $.cookie('cisit292014', $.cookie('cisit292014') + '1' , {expires: 15, path: '/'});
    //alert($.cookie('cisit292014'));
    }, 20000);
    });

    function dosurvey(pageURL, title, w, h) {
    var left = (screen.width - w) / 2;
    var top = (screen.height - h) / 6;  

    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
    }
    </script>

0 个答案:

没有答案