Use of Setinterval Method
Use of Setinterval Method
<html> <head> <title>DHTML</title> <script language="Javascript"> function show_time() { var todate=new Date(); var hh=todate.getHours(); var mm=todate.getMinutes(); var ss=todate.getSeconds(); document.f.t1.value=hh; document.f.t2.value=mm; document.f.t3.value=ss; } function show_t() { ref=setInterval("show_time()",1000); } function stop_t() { clearInterval(ref); } </script> </head> <body bgcolor="lightgreen"> <form name="f"> <h2>Digital Clock</h2> HH <input type="text" name="t1" value="">: MM <input type="textbox" name="t2" value="">: SS <input type="text" name="t3" value=""><br><br> <input type="button" name="b1" value="Show Time" onclick="show_t()"> <input type="button" name="b2" value="Stop Time" onclick="stop_t()"> </form> </body> </html>
OUTPUT:
OUTPUT:
OUTPUT:
Use Of Cookies:
(a)cookie.html <html> <head> <title>Handling Cookie in JavaScript</title> <script language="Javascript"> document.cookie="class=tycs"; document.cookie="degree=computer science"; alert(document.cookie); </script> </head> <body bgcolor="pink"> <h2>Cookie Created</h2> <a href ="2cookie.html">VIEW COOKIE</a> </body> </html> (b)2cookie.html <html> <body> <script language="Javascript"> document.writeln("<h2 style=color:green>" + document.cookie + "</h2>"); </script> </body> </html>
OUTPUT: