JAVASCRIPT   52

csspopup js

Guest on 13th August 2022 12:49:00 AM

  1. function toggle(div_id) {
  2.         var el = document.getElementById(div_id);
  3.         if ( el.style.display == 'none' ) {     el.style.display = 'block';}
  4.         else {el.style.display = 'none';}
  5. }
  6. function blanket_size(popUpDivVar) {
  7.         if (typeof window.innerWidth != 'undefined') {
  8.                 viewportheight = window.innerHeight;
  9.         } else {
  10.                 viewportheight = document.documentElement.clientHeight;
  11.         }
  12.         if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
  13.                 blanket_height = viewportheight;
  14.         } else {
  15.                 if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
  16.                         blanket_height = document.body.parentNode.clientHeight;
  17.                 } else {
  18.                         blanket_height = document.body.parentNode.scrollHeight;
  19.                 }
  20.         }
  21.         var blanket = document.getElementById('blanket');
  22.         blanket.style.height = blanket_height + 'px';
  23.         var popUpDiv = document.getElementById(popUpDivVar);
  24.         popUpDiv_height=blanket_height/2-150;//150 is half popup's height
  25.         popUpDiv.style.top = popUpDiv_height + 'px';
  26. }
  27. function window_pos(popUpDivVar) {
  28.         if (typeof window.innerWidth != 'undefined') {
  29.                 viewportwidth = window.innerHeight;
  30.         } else {
  31.                 viewportwidth = document.documentElement.clientHeight;
  32.         }
  33.         if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
  34.                 window_width = viewportwidth;
  35.         } else {
  36.                 if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
  37.                         window_width = document.body.parentNode.clientWidth;
  38.                 } else {
  39.                         window_width = document.body.parentNode.scrollWidth;
  40.                 }
  41.         }
  42.         var popUpDiv = document.getElementById(popUpDivVar);
  43.         window_width=window_width/2-150;//150 is half popup's width
  44.         popUpDiv.style.left = window_width + 'px';
  45. }
  46. function popup(windowname) {
  47.         blanket_size(windowname);
  48.         window_pos(windowname);
  49.         toggle('blanket');
  50.         toggle(windowname);            
  51. }

Raw Paste


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