Popular Posts
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... Word break tag : <wbr/> (HTML5) The  HTML  <wbr>  tag  is  used  defines  a  potential  line  break  point  if  needed.  This  stands  for  Word  BReak. This  is  u... 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <title>Example 7: Vertical alignment of content with JavaScript &amp; CSS</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        <!--
        #content
        {
            position: relative; /* Needed for Safari */
            margin: auto; /* Takes care of horizontal alignment in standards compliant browsers */
            text-align: left;
            width: 200px;
            height: 200px;
            background-color: #fc0;
        }
        h1, p
        {
            margin: 0;
            padding: 1em;
        }
        h1
        {
            font-size: 12px;
            line-height: 1.5em;
        }
        -->
    </style>

    <script type="text/javascript">
        <!--
        function getWindowHeight() {
            var windowHeight = 0;
            if (typeof (window.innerHeight) == 'number') {
                windowHeight = window.innerHeight;
            }
            else {
                if (document.documentElement && document.documentElement.clientHeight) {
                    windowHeight = document.documentElement.clientHeight;
                }
                else {
                    if (document.body && document.body.clientHeight) {
                        windowHeight = document.body.clientHeight;
                    }
                }
            }
            return windowHeight;
        }
        function setContent() {
            if (document.getElementById) {
                var windowHeight = getWindowHeight();
                if (windowHeight > 0) {
                    var contentElement = document.getElementById('content');
                    var contentHeight = contentElement.offsetHeight;
                    if (windowHeight - contentHeight > 0) {
                        contentElement.style.position = 'relative';
                        contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
                    }
                    else {
                        contentElement.style.position = 'static';
                    }
                }
            }
        }
        window.onload = function() {
            setContent();
        }
        window.onresize = function() {
            setContent();
        }
        //-->
    </script>

</head>
<body>
    <div style="position: relative; top: 121.5px;" id="content">
        <h1>
            Content</h1>
        <p>
            This content should be centered in your browser window. CSS is used for horizontal
            alignment, while scripting is used for vertical alignment.</p>
    </div>
</body>
</html>
reference : http://www.alistapart.com/d/footers/footer_variation1.html
function PageViewSize() {
    // initialize
    this.width = 0;
    this.height = 0;
    // determine window height
    function getWindowHeight() {
        var windowHeight = 0;
        if (typeof (window.innerHeight) == "number") {
            windowHeight = window.innerHeight;
        } else {
            if (document.documentElement && document.documentElement.clientHeight) {
                windowHeight = document.documentElement.clientHeight;
            } else {
                if (document.body && document.body.clientHeight) {
                    windowHeight = document.body.clientHeight;
                }
            }
        }
        return windowHeight;
    }
    // determine window width
    function getWindowWidth() {
        var windowWidth = 0;
        if (typeof (window.innerWidth) == "number") {
            windowWidth = window.innerWidth;
        } else {
            if (document.documentElement && document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            } else {
                if (document.body && document.body.clientWidth) {
                    windowWidth = document.body.clientWidth;
                }
            }
        }
        return windowWidth;
    }
    // assign current window size
    this.width = getWindowWidth();
    this.height = getWindowHeight();
    // method to get 'y' location of panel
    this.getTop = function(contentHeight) {
        if (this.height > 0 && this.height - contentHeight > 0) {
            return ((this.height - contentHeight) / 2);
        } else {
            return 0;
        }
    }
    // method to get 'x' location of panel
    this.getLeft = function(contentWidth) {
        if (this.width > 0 && this.width - contentWidth > 0) {
            return ((this.width - contentWidth) / 2);
        } else {
            return 0;
        }
    }
}
Conditional comments of IE
<!--[if gte IE 5]>
<marquee scrollAmount=3 direction=up width=200 height=150 style="background-color:lightyellow; border:1px solid black">
<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
</marquee>
<![endif]-->
reference : http://www.javascriptkit.com/howto/cc2.shtml