Posts

Window Screen Properties

 <!DOCTYPE html> <html> <body> <p id="demo"></p> <p id="demo1"></p> <p id="demo2"></p> <p id="demo3"></p> <p id="demo4"></p> <p id="demo5"></p> <script> document.getElementById("demo").innerHTML =  " screen width is " + screen.Width; document.getElementById("demo1").innerHTML =  "Available screen width is " + screen.availWidth; document.getElementById("demo2").innerHTML =  " screen height is " + screen.height; document.getElementById("demo3").innerHTML =  "Available screen height is " + screen.availHeight; document.getElementById("demo4").innerHTML =  " screen Depth is " + screen.colorDepth; document.getElementById("demo5").innerHTML =  "screen pixelDepth is " + screen.pixelDepth; </script> </body> <...

Javascript Code to Create Drawing on HTML Canvas

<!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="1000" height="500" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.fillStyle="yellow"; ctx.fillRect(400,50,350,400); ctx.fill(); ctx.stroke(); ctx.beginPath(); ctx.fillStyle="black"; ctx.arc(500,150,50,0,2*Math.PI); ctx.stroke(); ctx.fill(); ctx.beginPath(); ctx.fillStyle="white"; ctx.arc(500,180,20,0,2*Math.PI); ctx.stroke(); ctx.fill(); ctx.beginPath(); ctx.fillStyle="black"; ctx.arc(650,150,50,0,2*Math.PI); ctx.stroke(); ctx.fill(); ctx.beginPath(); ctx.fillStyle="white"; ctx.arc(650,180,20,0,2*Math.PI); ctx.stroke(); ctx.fill(); ctx.beginPath(); ctx.fillStyle="black"; ctx.fillRect(550,250,30,40,40);  ctx.stroke(); ctx.fil...

Javascript Code Using If Else to Compute Discount based on Grades

<html>    <body>           <script type = "text/javascript">          <!-- var grade= prompt("Enter grade");  var tuition=prompt("Enter tuition fee");            if (grade>=99)              {                discount=tuition *1;                document.write("<b> COngrats You Deserved 100% Discount " );              }            else if(grade >=95)                  {                 discount=tuition *.50;                document.write("<b> COngrats You Deserved 50% Discount " );               }    ...

Javascript Code using getElementById and If Else Statement

  <!DOCTYPE html> <html> <head> <title> Form Elements and Attributes </title> <style> //format and styles div { margin-bottom: 10px; } label { display: inline-block; width: 200px; } fieldset { background: #e1eff2; } legend { padding: 20px 0; font-size: 20px; } </style> <body> <body> <h1> Determine Age Group </h1> <p> Enter your details : </p> <fieldset> <label> Enter your name </label> <input type =" text " onfocus =" this.value='' " name =" fname " id =" fname " value ="" /> <br> <!-- create input text box for name --> <label> Enter your age </label> <input type =" number " onfocus =" this.value='' " name =" age " i...

Javascript Code Output document.write in the body

First Javascript Program place on the body

Javascript Sample Code : Using document.write in the body

 <html> <head> <title>First Javascript Program place on the body </title> </head>     <body>          <script language = "javascript" type = "text/javascript">          <!-- use comment for browsers that does not support javascipt            var name;                document.write("<br> welcome to Javascript Programming " );   name=prompt("Enter your name")        age=prompt("Enter your age");                document.write("<br> Name :  <b>" +name );                document.write("<br> Age :  <b>" + age );       course=prompt("Enter your Course");                document.write("<br> Course :  ...