Académique Documents
Professionnel Documents
Culture Documents
if (mystery<guess)
{
speech='Less than '+ guess;
}
if (mystery>guess)
{
speech='Greater than '+ guess;
}
if (guess=='')
{
speech='You didn\'t guess anything!'
}
document.forms.guessquiz.prompt.value=speech; document.forms.guessquiz.guess.focus();
}
</SCRIPT>
CONFIRMATION BOX
<!doctype html>
<html>
<head>
<title>CONFIRM</title>
</head>
<body>
<a href="www.google.co.in" onclick=alertmsg()> Google </a>
<script>
function alertmsg()
{
window.confirm("Do you Want to continue?")
}
</script>
</body>
</html>
PALINDROME
<html>
<body>
<script type="text/javascript">
function checkPalindrome() {
var revStr = "";
var str = document.getElementById("str").value;
var i = str.length;
for(var j=i; j>=0; j--) {
revStr = revStr+str.charAt(j);
}
if(str == revStr) {
alert(str+" -is Palindrome");
} else {
alert(str+" -is not a Palindrome");
}
}
</script>
<form >
Enter a String/Number: <input type="text" id="str" name="string" /><br />
<input type="submit" value="Check" onclick="checkPalindrome();"/>
</form>
</body>
</html>
CALCULATOR
<!doctype html>
<html>
<head>
</form>
</body>
</html>
SIMPLE CALCULATOR
<!doctype html>
<html>
<body>
<form name="form1">
</form>
<script>
function add()
{
var a,b,total;
a=document.form.v1.value;
b=document.form.v2.value;
total=a+b;
total=document.form.total.value;
}
function sub()
{
var a,b,total;
a=document.form.v1.value;
b=document.form.v2.value;
total=a-b;
total=document.form.total.value;
}
function mult()
{
var a,b,total;
a=document.form.v1.value;
b=document.form.v2.value;
total=a*b;
total=document.form.total.value;
}
function div()
{
var a,b,total;
a=document.form.v1.value;
b=document.form.v2.value;
total=a/b;
total=document.form.total.value;
}
function total()
{
window.write("total");
}
</script>
</body>
</html>
SUBJECT MARKS
<!doctype html>
<html>
<head>
</head>
<body>
<form name=f1>
<input type=text name=stuname> name </br>
<input type=number name=sub1> sub1 </br>
<input type=number name=sub2> sub2 </br>
<input type=number name=sub3> sub3 </br>
<input type=number name=sub4> sub4 </br>
<input type=number name=sub5> sub5 </br>
<input type=number name=total> total </br>
<input type=text name=result> result </br>
<input type=button name=calculate value="calculate" onclick=total()>
</form>
<script>
fuction total()
{
var a,b,c,d,e,name,total;
name=document.f1.stuname.value;
a=document.f1.sub1.value;
b=document.f1.sub2.value;
c=document.f1.sub3.value;
d=document.f1.sub4.value;
e=document.f1.sub5.value;
total=a+b+c+d+e;
total=document.f1.total.value;
}
if (a>50&&b>50&&c>50&&d>50&&e>50)
{
result="pass";
result=document.f1.result.value;
}
else
{
result="fail";
result=document.f1.result.value;
}
</script>
</body>
</html>
1&3
<!doctype html>
<html>
<body>
<button onmouseover="myFunction()">POPUP</button>
<script>
function myFunction() {
var a = window.open("", "", "width=200,height=100");
var b = prompt("Name");
var c = prompt("What has a foot but no legs?");
var d="snail";
var e=b+" "+"your answer is correct";
var f=b+" "+"Wrong answer,The correct answer is snail";
if(c==d)
{alert(e);}
else{
alert(f);}
}
</script>
</body>
</html>
2
<!DOCTYPE html>
<html>
<head>
<title>Cycling Banner</title>
<script>
window.onload = rotate;
var theAd = 0;
var adImages = new Array("banner1.jpg","banner3.jpg","banner2.jpg","banner4.jpg","banner5.jpg");
var Link = new
Array("https://www.youtube.com/?gl=IN","https://www.google.co.in/?gfe_rd=cr&ei=FEmWVNzjO6XM8
geeioHAAg&gws_rd=ssl","https://www.facebook.com/?stype=lo&jlou=AfegTmi57PSYXUx4Ya7zdARTOVuj4_PSfRKPgC-uifHLloFbAPwIA46MOiOO-3GSpe84DUFYm02eXna_Qnlk7zdACFfHrZkDbiPDrVvBh5w&smuh=1554&lh=Ac89BHacJaa6bNuD&aik=XfpVtS4DLMu9tGiSf41BxQ","http://www.airtel.in/smartby
te-s/page.html","https://in.yahoo.com/");
function rotate() {
theAd++;
if (theAd == adImages.length) {
theAd = 0;
}
document.getElementById("adBanner").src = adImages[theAd];
document.getElementById("link").href = Link[theAd];
setTimeout(rotate, 5000);
}
</script>
</head>
<body>
<div>
<center>
<a href="google.com" id="link"><img src="banner1.jpg" id="adBanner" alt="Ad Banner"
height="500px" width="500px"> </a>
</center>
</div>
</body>
</html>
4 time
<!doctype html>
<html>
<head>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
BUTTONS
<!doctype html>
<html>
<body id="color">
function but1()
{
a = window.open("", "", "width=500,height=100");
}
function but2()
{
a.close();
}
function but3()
{
b=window.close("5.html");
b.close();
}
function but4()
{
document.body.style.backgroundColor = "red";
}
function but5()
{
document.body.style.backgroundColor = "blue";
}
function but6()
{
document.body.style.backgroundColor = "green";
}
</script>
</body>
</html>