Website Code
Website Code
DOCTYPE html>
<html>
<head>
<meta-charset="utf-8">
<title>Buttons </title>
<style>
#my1 {
width:100px;
height:300px;
background-color:green;
color:white;
font-size: 20px;
text-align: center;
#my2 {
width:auto;
height:200px;
background-color:teal;
color:white;
font-size: 28px;
text-align: center;
padding:10px;
</style>
</head>
<body>
<div id="my1">
</div>
<hr />
<div id="my2">
<script type="text/javascript">
var x, y, z, myColor;
document.getElementById("btn4").onclick=function(){
x =Math.round(Math.random()*256);
y =Math.round(Math.random()*256);
z =Math.round(Math.random()*256);
document.getElementById("my1").style.backgroundColor= myColor;
document.getElementById("btn3").onmouseleave=function(){
document.getElementById('my2').style.backgroundColor = color;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta-charset="utf-8">
<title>Buttons </title>
<style>
#my1 {
width:100px;
height:300px;
background-color:green;
color:white;
font-size: 20px;
text-align: center;
#my2 {
width:auto;
height:200px;
background-color:teal;
color:white;
font-size: 28px;
text-align: center;
padding:10px;
</style>
</head>
<body>
<div id="my1">
</div>
<hr />
<div id="my2">
<script type="text/javascript">
/*
//function greeting(firstname){
//window.alert("Hello" + ' ' + firstname + '!');
*/
//greeting('Bakhsh Al Baloshi');
function sum(a,b){
return a*b;
var x = sum(5,11);
//window.alert(x);
function swap(id1,id2){
var y =document.getElementById(id1).innerHTML;
var z =document.getElementById(id2).innerHTML;
document.getElementById(id2).innerHTML= y;
document.getElementById(id1).innerHTML= z;
};
var mycar = {
color: 'White',
modle: 'Glaxy',
warranty: 24,
name: 'Glaxy'
window.console.log(mycar);
delete mycar.modle;
window.console.log(mycar);
mycar.modle = "plus";
</script>
</body>
</html>
<script>
myCar.make = "Honda";
myCar.color = "red";
myCar.price = "100";
window.console.log(myCar);
delete myCar.color;
window.console.log(myCar);
myCar.year = "2021";
window.console.log(myCar);
</script>
/************************************************/
<script>
function car(make,modle,year,color,warranty){
this.make = make;
this.modle = modle;
this.year = year;
this.color = color;
this.warranty = warranty;
this.extandWarranty = function(x){
this.warranty += x;
window.console.log(myCar);
myCar.extandWarranty(24);
window.console.log(myCar);
window.console.log(myCar.condition);
window.console.log(mySonCar);
car.prototype.condition = "New";
window.console.log(myCar);
function showResult(x){
showResult(shoppingList);
showResult(shoppingList[0]);
showResult(shoppingList[2]);
shoppingList[1] = "Orange";
showResult(shoppingList);
shoppingList.splice(1,1);
showResult(shoppingList);
shoppingList.splice(1,0,"Laptop","Sugar");
showResult(shoppingList);
shoppingList.sort();
showResult(shoppingList);
shoppingList.reverse();
showResult(shoppingList);
showResult(myArray);
</script>
<script>
else {
</script>
//////////////// MotorWay Speed Check ///////////////////////
<body>
</p>
</p>
<script>
function checkSpeed(){
else {
</script>
</body>
</html>
/////////////////////////////////////// Switch Case Statement /////////////////////////////
</p>
<br />
</p>
</p>
<script>
function checkSpeed(){
else {
function checkSeason(){
var x = document.getElementById("season").value.toLowerCase();
switch(x){
case "summer":
break;
case "winter":
break;
case "fall":
break;
case "atumm":
break;
default:
</script>
</body>
</html>
/////////////////// JavaScript //////////////////////////
</p>
<br />
</p>
</p>
</p>
<script>
function checkSpeed(){
else {
window.alert("Your speed is fine ");
function checkSeason(){
var x = document.getElementById("season").value.toLowerCase();
switch(x){
case "summer":
break;
case "winter":
break;
case "fall":
break;
case "atumm":
break;
default:
}
for(i= 0; i < 6; i++){
numberList[i] += 10;
</script>
</body>
</html>
</p>
<br />
<p> Check Season <input id ="season" />
</p>
</p>
</p>
<script>
function checkSpeed(){
else {
function checkSeason(){
var x = document.getElementById("season").value.toLowerCase();
switch(x){
case "summer":
break;
case "winter":
window.alert(" It is Winter ! ");
break;
case "fall":
break;
case "atumm":
break;
default:
var i = 0;
i++;
function startGame(){
var itemsBought = 0;
itemsBought += 1;
balance -= itemPrice;
}
}
</script>
</body>
</html>
window.alert(str.search(pattern));
window.alert(str.match(pattern));
<script>
document.getElementById("string").innerHTML = str;
document.getElementById("pattern").innerHTML = pattern;
document.getElementById("search").innerHTML = str.search(pattern);
document.getElementById("match").innerHTML = str.match(pattern);
document.getElementById("test").innerHTML = pattern.test(str);
</script>
</body>
</html>
/////////////////// Password Matching and Error Handling /////////////////////
<p> Your Password Should Contain one Capital letter and one number.</p>
<p> Re-Enter Your Password : <br /> <input id="password2" type="password"> </p>
<script>
//try{
// sum(4,7);
//}
//catch(err){
// document.getElementById("error").innerHTML = err.message;
//}
function check(){
try{
if(password.length<6){
if(/[A-Z]/g.test(password) == false){
errorToThrow += "<br /> Your Password Should Contain at least one Capital Letter. !.";
if(/\d/g.test(password) == false){
errorToThrow += "<br /> Your Password Should Contain at least one number!";
if(password != password2){
throw errorToThrow;
catch(err){
errorMessage.innerHTML = err;
</script>
</body>
</html>
<br />
<script>
//try{
// sum(4,7);
//}
//catch(err){
// document.getElementById("error").innerHTML = err.message;
//}
var x = 0;
</script>
</body>