Search This Blog

Showing posts with label Java Script. Show all posts
Showing posts with label Java Script. Show all posts

Monday, October 14, 2013

Center DIV

CSS margin property sets all the margin properties (top, right, bottom, left).

<div style="border: thin solid #C0C0C0; width: 800px;margin:0 auto;">
        centered content
</div>





Tuesday, March 26, 2013

Object JavaScript

In JavaScript you can define and create your own objects.





<!DOCTYPE html>
<html>
<body>

<script>
    var car = new Object();
    car.type = "Audi";
    car.speed = "300";
    document.write(car.type + " speed is " + car.speed + " KM/Hour.");
</script>

</body>
</html>




Display date Java Script

Java Script > Date

<!DOCTYPE html>
<html>
<head>
<script>
    function displayDate() {
        document.getElementById("date").innerHTML = Date();
    }
</script>
</head>
<body>
    <h1>Display date JavaScript</h1>
<p id="date">Click button to display date</p>
<button type="button" onclick="displayDate()">Display Date</button>
</body>
</html>  




Friday, August 31, 2012

Height div to window height with scroll

Java > Height div to window height with scroll

<script type="text/javascript" language="javascript">

    window.onload = function () { SizeDiv(); }

    function getDocHeight() {

        var D = document;

        return Math.max(

        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),

        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),

        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );

    }

    function SizeDiv() {
        
        document.getElementById('leftCol').style.height = getDocHeight()-175 + "px";
     
    }

</script>