Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Friday, 31 August 2018

Clock Wise / Anti Clock Wise Stopwatch in JavaScript

:: Code ::

<html>
<head>
<title>stopwatch</title>
<script type="text/javascript">
var c=60;
var c2=0;
var t,t2;
function stopCount()
{
clearTimeout(t)
}
function stopCount2()
{
clearTimeout(t2)
}
function timedCount()
{
document.getElementById('txt').value=c
c=c-1
if(c==-1)
{
alert("time over")
stopcount()
}
t=setTimeout("timedCount()",1000)
}
function timedCount2()
{
document.getElementById('txt2').value=c2
c2=c2+1
if(c2==61)
{
alert("time over")
stopcount2()
}
t=setTimeout("timedCount2()",1000)
}
</script>
</head>
<body>
<center>
<form>
 <input type="text" id="txt">
 <input type="button" value="Start stopwatch (Anti Clock Wise)" onClick="timedCount()">
 <input type="button" value="Stop" onClick="stopCount()">
 <br/>
 <br/>
 <input type="text" id="txt2">
 <input type="button" value="Start stopwatch (Clock Wise)" onClick="timedCount2()">
 <input type="button" value="Stop" onClick="stopCount()">
</form>
<center>
</body>
</html>

:: Example ::




Thursday, 3 April 2014

Image Slider using Javascript without using jQuery.

abcd.html

<html>
<head>
<title> Auto Change Background Color </title>
<style type="text/css">
div
{
height:320px;
width:100%;
}
</style>
<script type = "text/javascript">
var image = new Array ('pic-1.jpg', 'pic-2.jpg', 'pic-3.jpg', 'pic-10.jpg','pic-11.jpg');

var image_index = 0;
function ChangeBgImage ()
 {

   document.getElementById("ddiv").style.backgroundImage="url("+image[image_index]+")";
    image_index++;
    if (image.length == image_index)
     {
           image_index = 0;   
      }   
}
setInterval( "ChangeBgImage()", 1000);
</script>
</head>
<body>
<div id="ddiv">
</div>
</body>
</html>

Image Slider using Only CSS without using Javascript or JQuery.

Slidercss.css
@keyframes slidy
{
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}

body { margin: 0; }
div#slider { overflow: hidden; }
div#slider div img { width: 20%; }
div#slider div {
  position: relative;
  width: 500%;
  margin: 0;
  left: 0;
  font-size: 0;
  animation: 30s slidy infinite;
}


Slider.html:

<html>
<head>
<link rel="stylesheet" type="text/css" href="Slidercss.css"/>
</head>
<body>
<div id="slider">
<div>
<img src="pic-1.jpg" alt="">
<img src="pic-2.jpg" alt="">
<img src="pic-3.jpg" alt="">
<img src="pic-10.jpg" alt="">
<img src="pic-11.jpg" alt="">
</div>
</div>
</body>
</html>