An example to demonstrate how start interval & stop it using javascript.

var x = window.setInterval(
	function(greeting, name){
		var m = document.createElement("div");
                with(m.style){
                    height = "2px";
                    width = "50px";
                    position = "relative";
                    backgroundColor= "green";
                }
                document.body.appendChild(m);
	},
	1000,
	"hello",
	"world",
        document.body.onclick = function(){
	    clearInterval(x)
        }
);
 

Here’s how we create javascript object using Javascript Object Notation (JSON). After the code below is executed, it would show alert windows with text “Borey Lim”

//script to demonstrate creating object in javascript using JSON

var objectDemo = {
	firstName: "",
	lastName: "",
	displayName : function(){
		alert(this.firstName + " " + this.lastName);
	}
}

objectDemo.firstName = "Borey";
objectDemo.lastName = "Lim";
objectDemo.displayName();
May 012009
 

In table of height 500px, if we have 2 rows and we set the first one 100px, the second will fill in the rest of the space. In CSS, we can all so make our div behave the same as table. Here sample code:

<html>
  <head>
    <style>
    #main {
      height: 100%;
      width: 100%;
      position: relative;
    }
    #top{
      background-color: blue;
      height: 200px;
    }
    #bottom{
      background-color: gray;
      position: absolute;
      bottom: 0px;
      top: 200px;
      width: 100%
    }
    </style>
  </head>
  <body>
    <div id="main">
      <div id="top"></div>
      <div id="bottom"></div>
    </div>
  </body>
</html>
© 2012 Programming & technology Suffusion theme by Sayontan Sinha