Page 172 - Computer Software Application TP - Volume 1
P. 172

COMPUTER SOFTWARE APPLICATION - CITS




           TASK 3 : Create and display a cookie using a user defined function
           1  Open the text editor
           2  Write the following codes

              <html>
              <head>
              <script>
              function setCookie()

              {
              document.cookie=”username=Duke Martin”;
              }
              function getCookie()
              {
              if(document.cookie.length!=0)

              {
              alert(document.cookie);
              }
              else

              {
              alert(“Cookie not available”);
              }
              }
              </script>

              </head>
              <body>
              <input type=”button” value=”setCookie” onclick=”setCookie()”>
              <input type=”button” value=”getCookie” onclick=”getCookie()”>

              </body>
              </html>
           3  Save the program as a .html file
           4  Open the html file with a web browser and verify the output.























                                                           157
 CITS : IT & ITES - Computer Software Application - Exercise 43  CITS : IT & ITES - Computer Software Application - Exercise 43
   167   168   169   170   171   172   173   174   175   176   177