Page 171 - Computer Software Application TP - Volume 1
P. 171
COMPUTER SOFTWARE APPLICATION - CITS
TASK 2: Create a cookie and display its value using innerHTML property
1 Open the text editor
2 Write the following codes
<html>
<head>
<title> Cookies </title>
</head>
<body>
<p id=”para”>javascript cookies</p>
<script>
document.cookie=”username=sun”;
document.cookie=”age=33”;
document.cookie=”country=india”;
var cookie=document.cookie.split(“;”);
for(i=0;i<cookie.length;i++)
{
document.getElementById(“para”).innerHTML+=”<br />”+cookie[i];
}
</script>
</body>
</html>
3 Save the program as a .html file
4 Open the html file with a web browser and verify the output.
156
CITS : IT & ITES - Computer Software Application - Exercise 43