javascript - How do you create a custom css pop-up to open on page load once per visitor per week -


okay have below code, allow me either click link or hover on link show pop-up. able edit make open on page load. able have open once per visitor per week.

i new great!

thanks

    <head>  <style type="text/css"> #fade {     display: none;     background: #000;      position: fixed; left: 0; top: 0;      z-index: 10;     width: 100%; height: 100%;     opacity: .80;     z-index: 9999; } .popup_block{     display: none;     background: #fff;     float: left;     font-size: 1.2em;     position: fixed;     padding: 20px;          border: 20px solid #ddd;     top: 50%; left: 50%;     z-index: 99999;     -webkit-box-shadow: 0px 0px 20px #000;     -moz-box-shadow: 0px 0px 20px #000;     box-shadow: 0px 0px 20px #000;     -webkit-border-radius: 10px;     -moz-border-radius: 10px;     border-radius: 10px; } img.btn_close {     float: right;      margin: -55px -55px 0 0; } .popup p {     padding: 5px 10px;     margin: 5px 0; } /*--making ie6 understand fixed positioning--*/ *html #fade {     position: absolute; } *html .popup_block {     position: absolute; } </style>  </head> <body>  <a href="#?w=200" rel="popup1" class="poplight">hover see pop-up</a>  <div id="popup1" class="popup_block"> test     </div>  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){      //when click on link class of poplight , href starts #      $('a.poplight[href^=#]').hover(function() {         var popid = $(this).attr('rel'); //get popup name         var popurl = $(this).attr('href'); //get popup href define size          //pull query & variables href url         var query= popurl.split('?');         var dim= query[1].split('&');         var popwidth = dim[0].split('=')[1]; //gets first query string value          //fade in popup , add close button         $('#' + popid).fadein().css({ 'width': number( popwidth ) }).prepend('<a href="#" class="close"><img src="http://www.sohtanaka.com/web-design/examples/modal-window/close_pop.png" class="btn_close" title="close window" alt="close" /></a>');          //define margin center alignment (vertical + horizontal) - add 80 height/width accomodate padding + border width defined in css         var popmargtop = ($('#' + popid).height() + 80) / 2;         var popmargleft = ($('#' + popid).width() + 80) / 2;          //apply margin popup         $('#' + popid).css({              'margin-top' : -popmargtop,             'margin-left' : -popmargleft         });          //fade in background         $('body').append('<div id="fade"></div>'); //add fade layer bottom of body tag.         $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadein(); //fade in fade layer           return false;     });       //close popups , fade layer     $('a.close, #fade').live('click', function() { //when clicking on close or fade layer...           $('#fade , .popup_block').fadeout(function() {             $('#fade, a.close').remove();       }); //fade them both out          return false;     });   });  </script>  </body> 

you'll have include in user table last time shown popup. whenever user first visits site (or logs in) check current timestamp against last popup timestamp. if been week show popup , update users popup timestamp current timestamp.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -