JAVASCRIPT   74
pops js
Guest on 3rd May 2022 09:48:46 AM


  1.  
  2. $.fn.createwindow = function ()
  3. {
  4.        
  5.         var windowwidth         =       $(window).width();
  6.         var windowheight        =       $(window).height();
  7.         var height                      =       $(document).height();
  8.         var srciz_width         =       $(this).width();
  9.         var srciz_height        =       $(this).height();
  10.  
  11.         if(srciz_width<=0)
  12.         {
  13.                 alert('Popup content is not loaded properly, please try again..')
  14.                 return false;
  15.         }
  16.        
  17.         var left = (windowwidth-srciz_width)/2;
  18.         var top  = (windowheight - srciz_height)/2
  19.        
  20.         /*if(windowsTop<200)
  21.                 $('html, body').animate( {scrollTop: 250},500);*/
  22.        
  23.         $("#overlayByN").css({
  24.                 "background": '#00000C',  
  25.                 "opacity": "0.85",
  26.                 "height": height
  27.         });
  28.         $("#overlayByN").fadeIn();
  29.        
  30.         $(this).css({
  31.                 position:'fixed',              
  32.                 top:top,
  33.                 left:left
  34.         });
  35.         $(this).fadeIn();
  36.         //alert(windowwidth+','+windowheight+','+windowsTop+','+srciz_width+','+srciz_height+','+left+','+top)
  37.        
  38. }
  39.  
  40. $.fn.closewindow = function ()
  41. {
  42.         $(this).fadeOut();
  43.         $("#overlayByN").fadeOut();
  44. }
  45.  
  46. $(document).ready(function(){
  47.         $("#overlayByN").click(function(){$(".popup").closewindow(1);});                                                   
  48.         $(document).keypress(function(e){
  49.                 if(e.keyCode==27){
  50.                         $(".popup").closewindow(1);
  51.                 }
  52.         });
  53. });

Raw Paste

Login or Register to edit or fork this paste. It's free.