Tuesday 22 January 2013

Clock in a visualforce Page

**************CLOCK in a visual force page******************* 

                 quiet interesting !! is it ??????????

=================================================================================
>                Yes it can be done with help of some basics in html , with this you can even create   a     stop watch or countdown timer  TOO  but for now i came up with an example of clock which will be displayed on the visual force page and which can be stopped even .
And here is the code for it ...........!!!!!!!!
==========================================================================================
VISUAL FORCE PAGE:-
==========================================================================================
<apex:page id="thePage" showHeader="false"><html>
<body>
<center>
<div id="clock"></div>
</center>
<br/>
<div align="right">
<button onclick="int=window.clearInterval(int);" id="stop">Stop Clock</button>
</div>
</body>
<script type="text/javascript">
var int = self.setInterval("clock()",1000);
function clock()
{
    var d=new Date();
    var t=d.toLocaleTimeString();
    document.getElementById("clock").innerHTML = "<B>" + t + "</B>";
}
</script>
</html>
</apex:page>
============================================================================================
You can play around with "set Interval" and "clear Interval" functions to create a stop watch or countdown timer code.

Hope this was interesting and useful.

Happy Clouding.. :)...:)...:)

1 comment:

  1. This is great Rohit,
    Could you help me with countdown timer,, ? how to implement that ?

    ReplyDelete