Inline JavaScript Example in JavaScript

Definition :     It is a process of writing java script code within the html tags then it is called as inline java script. Program 1 : <html>      <body>                      <h1> HELLO WELCOME </h1>                                  <input type=”button” value=”print me” onclick=”window.print()”/> </br>                 </body> </html> Program 2: <html>      …

History Examples in JavaScript

Definition : History object represents an array of URLs visited by the user. by using this object you can load previous, forward or any particular page. The history object is the window property, so it can be accessed by: window.history Program 1  : <html>    <head>       <script language=”javascript”>                 …

Hoaisting Example in JavaScript

Definition : Declaration of variables after it is used then it is called as hoaisting. Program : <html>    <head>       <script language=”javascript”>                    function display()                    {                    “use strict”;                    //do add;                   a=document.getElementById(“dd”);                   b=document.createElement(“input”);                   b.setAttribute(“type”,”text”);                   b.setAttribute(“id”,”t1″); …

Strict Mode Example in JavaScript

Definition :  Strict mode forces user to declare the variables in the program. Program : <html>    <head>       <script language=”javascript”>                    var a,b;                    function display()                    {                    “use strict”;                    //do add;                   a=document.getElementById(“dd”);                   b=document.createElement(“input”);                   b.setAttribute(“type”,”text”);                 …

Dynamic CSS Examples in JavaScript

Definition : It is a process of applying css dynamically then it is called as dynamic css. Program 1 : <html>      <head>                      <script language=”javascript”>                                      function display()                                                  {                                                     a=document.getElementById(“demo”);                                                                 a.setAttribute(“style”,”color:red; background-color:green; width=100px; height=100px;”);                                                   }                                 </script>                 </head>                 <body> …

JSON Examples in JavaScript

Definition : It is a representation which will be used for holding the data in array and object format. Program 1 : <html>    <head>       <script language=”javascript”>                      function display()                                  {                                  a='[{“name”:”arif”,”age”:24},{“name”:”ranga”,”age”:30}]’;                                  b=JSON.parse(a);                                  for(i=0;i<b.length;i++)                                  document.write(b[i].name+” “+b[i].age+”</br>”);                                  }                   </script>                 </head> …

Window Examples in JavaScript

Definition : It is an object of java script which is meant for performing the operations on the browser window. Program 1 : <html>      <head>                      <script language=”javascript”>                                      function display()                                                  {                                                      window.location=”Desert.jpg”;                                                   }                                 </script>                 </head>                 <body>                      …

Onerror Example in JavaScript

Definition : This is a event which triggers a function whenever an exception has been encountered in the image. Program : <html>    <head>       <script language=”javascript”>                       function display()                                   {                                                 alert(“sorry couldn’t find image”);                                                  }                                 </script>     </head>                 <body>                   <img …

Exception Handling Examples in JavaScript

Definition :   It is an abnormal condition which terminates the program during its run time. Types of exception handling : Exception handlers are the keyboards which handles the exception during its runtime. Try Catch Finally Throw Program : <html>      <head>                      <script language=”javascript”>                                     function display() …