bychloethemes

Pop up window - JQuery Script

Apr 6th, 2015
2,820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
  2. <script type="text/javascript">
  3. $(document).ready(function() {
  4.  
  5. if (once_per_session==0)
  6. loadpopunder()
  7. else
  8. {
  9. if (get_cookie('popunder')==''){
  10. loadpopunder()
  11. document.cookie="popunder=yes"
  12. }
  13. }
  14.  
  15.  
  16.  
  17. });
  18. </script>
  19.  
  20. <script type="text/javascript">
  21.  
  22. //Pop-under window II- By JavaScript Kit
  23. //Credit notice must stay intact for use
  24. //Visit http://javascriptkit.com for this script
  25.  
  26. //Pop-under only once per browser session? (0=no, 1=yes)
  27. //Specifying 0 will cause popunder to load every time page is loaded
  28. var once_per_session=1
  29.  
  30. ///No editing beyond here required/////
  31.  
  32. function get_cookie(Name) {
  33. var search = Name + "="
  34. var returnvalue = "";
  35. if (document.cookie.length > 0) {
  36. offset = document.cookie.indexOf(search)
  37. if (offset != -1) { // if cookie exists
  38. offset += search.length
  39. // set index of beginning of value
  40. end = document.cookie.indexOf(";", offset);
  41. // set index of end of cookie value
  42. if (end == -1)
  43. end = document.cookie.length;
  44. returnvalue=unescape(document.cookie.substring(offset, end))
  45. }
  46. }
  47. return returnvalue;
  48. }
  49.  
  50. function loadornot(){
  51. if (get_cookie('popunder')==''){
  52. loadpopunder()
  53. document.cookie="popunder=yes"
  54. }
  55. }
  56. function loadpopunder(){
  57. var id = '#popup';
  58.  
  59.  
  60. //Get the screen height and width
  61. var maskHeight = $(document).height();
  62. var maskWidth = $(window).width();
  63.  
  64. //Set heigth and width to mask to fill up the whole screen
  65. $('#mask').css({'width':maskWidth,'height':maskHeight});
  66.  
  67. //transition effect
  68. $('#mask').fadeIn(1000);
  69. $('#mask').fadeTo("slow",0.8);
  70.  
  71. //Get the window height and width
  72. var winH = $(window).height();
  73. var winW = $(window).width();
  74.  
  75. //Set the popup window to center
  76. $(id).css('top', winH/2-$(id).height()/2);
  77. $(id).css('left', winW/2-$(id).width()/2);
  78.  
  79. //transition effect
  80. $(id).fadeIn(2000);
  81.  
  82.  
  83. //if close button is clicked
  84. $('.window .close').click(function (e) {
  85. //Cancel the link behavior
  86. e.preventDefault();
  87.  
  88. $('#mask').hide();
  89. $('.window').hide();
  90. });
  91.  
  92. //if mask is clicked
  93. $('#mask').click(function () {
  94. $(this).hide();
  95. $('.window').hide();
  96. });
  97. }
  98.  
  99. </script>
Advertisement
Add Comment
Please, Sign In to add comment