Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... Build an OpenVPN server on android device Preparation An android device, in this case, Sony xperia Z is used Root permission required Linux Deploy for deploy i...
Stats
Centralize popup div
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
  2. <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
  3. <head>
  4.     <title>Example 7: Vertical alignment of content with JavaScript &amp; CSS</title>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6.     <style type="text/css">
  7.         <!--
  8.         #content
  9.         {
  10.             position: relative; /* Needed for Safari */
  11.             margin: auto; /* Takes care of horizontal alignment in standards compliant browsers */
  12.             text-align: left;
  13.             width: 200px;
  14.             height: 200px;
  15.             background-color: #fc0;
  16.         }
  17.         h1, p
  18.         {
  19.             margin: 0;
  20.             padding: 1em;
  21.         }
  22.         h1
  23.         {
  24.             font-size: 12px;
  25.             line-height: 1.5em;
  26.         }
  27.         -->
  28.     </style>
  29.  
  30.     <script type="text/javascript">
  31.         <!--
  32.         function getWindowHeight() {
  33.             var windowHeight = 0;
  34.             if (typeof (window.innerHeight) == 'number') {
  35.                 windowHeight = window.innerHeight;
  36.             }
  37.             else {
  38.                 if (document.documentElement && document.documentElement.clientHeight) {
  39.                     windowHeight = document.documentElement.clientHeight;
  40.                 }
  41.                 else {
  42.                     if (document.body && document.body.clientHeight) {
  43.                         windowHeight = document.body.clientHeight;
  44.                     }
  45.                 }
  46.             }
  47.             return windowHeight;
  48.         }
  49.         function setContent() {
  50.             if (document.getElementById) {
  51.                 var windowHeight = getWindowHeight();
  52.                 if (windowHeight > 0) {
  53.                     var contentElement = document.getElementById('content');
  54.                     var contentHeight = contentElement.offsetHeight;
  55.                     if (windowHeight - contentHeight > 0) {
  56.                         contentElement.style.position = 'relative';
  57.                         contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
  58.                     }
  59.                     else {
  60.                         contentElement.style.position = 'static';
  61.                     }
  62.                 }
  63.             }
  64.         }
  65.         window.onload = function() {
  66.             setContent();
  67.         }
  68.         window.onresize = function() {
  69.             setContent();
  70.         }
  71.         //-->
  72.     </script>
  73.  
  74. </head>
  75. <body>
  76.     <div style="position: relative; top: 121.5px;" id="content">
  77.         <h1>
  78.             Content</h1>
  79.         <p>
  80.             This content should be centered in your browser window. CSS is used for horizontal
  81.             alignment, while scripting is used for vertical alignment.</p>
  82.     </div>
  83. </body>
  84. </html>
reference : http://www.alistapart.com/d/footers/footer_variation1.html
  1. function PageViewSize() {
  2.     // initialize
  3.     this.width = 0;
  4.     this.height = 0;
  5.     // determine window height
  6.     function getWindowHeight() {
  7.         var windowHeight = 0;
  8.         if (typeof (window.innerHeight) == "number") {
  9.             windowHeight = window.innerHeight;
  10.         } else {
  11.             if (document.documentElement && document.documentElement.clientHeight) {
  12.                 windowHeight = document.documentElement.clientHeight;
  13.             } else {
  14.                 if (document.body && document.body.clientHeight) {
  15.                     windowHeight = document.body.clientHeight;
  16.                 }
  17.             }
  18.         }
  19.         return windowHeight;
  20.     }
  21.     // determine window width
  22.     function getWindowWidth() {
  23.         var windowWidth = 0;
  24.         if (typeof (window.innerWidth) == "number") {
  25.             windowWidth = window.innerWidth;
  26.         } else {
  27.             if (document.documentElement && document.documentElement.clientWidth) {
  28.                 windowWidth = document.documentElement.clientWidth;
  29.             } else {
  30.                 if (document.body && document.body.clientWidth) {
  31.                     windowWidth = document.body.clientWidth;
  32.                 }
  33.             }
  34.         }
  35.         return windowWidth;
  36.     }
  37.     // assign current window size
  38.     this.width = getWindowWidth();
  39.     this.height = getWindowHeight();
  40.     // method to get 'y' location of panel
  41.     this.getTop = function(contentHeight) {
  42.         if (this.height > 0 && this.height - contentHeight > 0) {
  43.             return ((this.height - contentHeight) / 2);
  44.         } else {
  45.             return 0;
  46.         }
  47.     }
  48.     // method to get 'x' location of panel
  49.     this.getLeft = function(contentWidth) {
  50.         if (this.width > 0 && this.width - contentWidth > 0) {
  51.             return ((this.width - contentWidth) / 2);
  52.         } else {
  53.             return 0;
  54.         }
  55.     }
  56. }
Conditional comments of IE
  1. <!--[if gte IE 5]>
  2. <marquee scrollAmount=3 direction=up width=200 height=150 style="background-color:lightyellow; border:1px solid black">
  3. <p><img src="http://javascriptkit.com/dot.gif"> Two wrongs don’t make a right. -Cheales<p><img src="http://javascriptkit.com/dot.gif"> A bird in the hand is worth two in the bush. -Heywood <p><img src="http://javascriptkit.com/dot.gif"> The opposite of love is indifference. -Erin<p><img src="http://javascriptkit.com/dot.gif"> All is well that ends well. -Shakespeare
  4. </marquee>
  5. <![endif]-->
reference : http://www.javascriptkit.com/howto/cc2.shtml