Posts

Click the following to see the result

<html>

   <head>

      <script type="text/javascript">
         <!--
            function myFunc()
            {
               var a = 100;
               try {
                  alert("Value of variable a is : " + a );
               }

               catch ( e ) {
                  alert("Error: " + e.description );
               }
            }
         //-->
      </script>

   </head>

   <body>
      <p>Click the following to see the result:</p>

      <form>
         <input type="button" value="Click Me" onclick="myFunc();" />
      </form>

   </body>
</html>

User-defined objects

<html>
   <head>

   <title>User-defined objects</title>

      <script type="text/javascript">
         function book(title, author){
            this.title = title;
            this.author  = author;
         }
      </script>

   </head>
   <body>

      <script type="text/javascript">
         var myBook = new book("Perl", "Mohtashim");
         document.write("Book title is : " + myBook.title + "<br>");
         document.write("Book author is : " + myBook.author + "<br>");
      </script>

   </body>
</html>

Click the following button to see the result

<html>
   <head>

      <script type="text/javascript">
         <!--
            function getValue(){
               var retVal = prompt("Enter your name : ", "your name here");
               document.write("You have entered : " + retVal);
            }
         //-->
      </script>

   </head>

   <body>
      <p>Click the following button to see the result: </p>

      <form>
         <input type="button" value="Click Me" onclick="getValue();" />
      </form>

   </body>
</html>

Click the following button to see the result:

<html>
   <head>

      <script type="text/javascript">
         <!--
            function Warn() {
               alert ("This is a warning message!");
               document.write ("This is a warning message ohh bay!");
            }
         //-->
      </script>

   </head>
   <body>
      <p>Click the following button to see the result: </p>

      <form>
         <input type="button" value="Click Me" onclick="Warn();" />
      </form>

   </body>
</html>

set a browser name and redirected link

<html>
   <head>

      <script type="text/javascript">
         <!--
            var browsername=navigator.appName;
            if( browsername == "Netscape" )
            {
               window.location="http://www.google.com";
            }
            else if ( browsername =="Microsoft Internet Explorer")
            {
               window.location="http://www.yahoo.com";
            }
            else
            {
               window.location="http://www.arenanagpur.com";
            }
         //-->
      </script>

   </head>

   <body>
   </body>
</html>

auto redirected page in java script

auto redirected
<html>
   <head>

      <script type="text/javascript">
         <!--
            function Redirect() {
               window.location="http://www.google.com";
            }

            document.write("You will be redirected to main page in 10 sec.");
            setTimeout('Redirect()', 10000);
         //-->
      </script>

   </head>

   <body>
   </body>
</html>