Client Side Scripting Unit-4
Client Side Scripting Unit-4
W-19 (12M)
Q.1. (g) State any two properties and methods of location object. (2M)
Q.3. (d) Explain open () method of window object with syntax and example. (4M)
Q.5. (b) Describe, how to read cookie value and write a cookie value. Explain with example. (6M)
W-22 (14M)
Q.3. (d) Write a JavaScript function that will open new window when the user will clicks on the button. (6M)
<html>
<body>
<script>
function openNew(){
window.open("","New Window","width=500,height=500")
}
</script>
<input type="button" value="Open A new Window" onclick="openNew()">
</body>
</html>
Q.5. (b) Write a webpage that displays a form that contains an input for user name and password. User is prompted
to enter the input user name and password and password becomes the value of the cookie. Write the
JavaScript function for storing the cookies. It gets executed when the password changes. (6M)
<html>
<body>
<form name="myform">
Username : <input type="text" name="user" id="user"><br>
Password : <input type="password" name="pass" id="pass"
onchange="updatePass()"><br>
<input type="button" value="Create cookie" onclick="storePass()">
<p id="panel"></p>
</form>
<script>
function storePass(){
var password=document.getElementById("pass").value;
document.cookie=password;
1
Unit-4 Cookies and Browser Data Vikas Patil
alert("Password : "+document.cookie);
}
function updatePass(){
var password=document.getElementById("pass").value;
document.cookie=password;
alert("Updated password : "+document.cookie);
}
</script>
</body>
</html>
S-22 (12M)
Q.1. (b) Differentiate between session cookies and persistent cookies. (2M)
Q.1. (e) Write a javascript program to changing the contents of a window. (2M)
<html>
<body>
<form>
<br><p id="para">Welcome to Javascript</p>
<input type="button" value="Change" onclick="changeContent()">
</form>
<script>
function changeContent(){
var change= "Javascript is a scripting language and not JAVA";
document.getElementById("para").innerHTML=change;
}
</script>
</body>
</html>
Q.2. (d) Design a webpage that displays a form that contains an input for user name and password. User is prompted
to enter the input user name and password and password become value of the cookies. Write the javascript
2
Unit-4 Cookies and Browser Data Vikas Patil
Q.3. (a) Write a javascript program to create read, update and delete cookies. (4M)
<html>
<head>
<script>
function writeCookie()
{
var d=new Date();
d.setTime(d.getTime()+(1000*60*60*24));
with(document.myform)
{
document.cookie="Name=" + person.value + ";expires="
+d.toGMTString();
}
}
function readCookie()
{
if(document.cookie=="")
document.write("cookies not found");
else
document.write(document.cookie);
}
</script>
</head>
<body>
<form name="myform" action="">
Enter your name:
<input type="text" name="person"><br>
<input type="Reset" value="Set" type="button" onclick="writeCookie()">
<input type="Reset" value="Get" type="button" onclick="readCookie()">
</form>
</body>
</html>
S-23 (12M)
Q.1. (g) State any four properties of Navigator object.. (2M)
Q.3. (d) Explain how to create and read Persistent Cookies in JavaScript with example. (4M)
Q.5. (b) Write HTML code to design a form that displays two buttons START and STOP. Write a JavaScript code such
that when user clicks on START button, real time digital clock will be displayed on screen. When user clicks
on STOP button, clock will stop displaying time. (Use Timer methods) (6M)
Done in Unit-3
<html>
<body>
<form name="myform">
<p>Star the Clock</p><br>
3
Unit-4 Cookies and Browser Data Vikas Patil
function myTimer() {
var d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
</script>
</body>
</html>
W-23 (18M)
Q.1. (f) Give syntax of and explain the use of small “with” clause. (2M)
Q.2. (b) Describe the “navigator” object of JavaScript. Describe the methods of navigator object which is used to
Q.3. (d) State what is a cookie ? Explain its need. State characteristics of persistent cookies. (4M)
Q.4. (d) List and state various properties of a window object. Write a JavaScript that opens a new popup window with
message “WELCOME To SCRIPTING” when the page loads and a new popup window displaying message “FUN
4
Unit-4 Cookies and Browser Data Vikas Patil
Q.4. (d) Give syntax of and explain the use of SetTime Out( ) function with the help of suitable example. (4M)
S-24 (12M)
Q.1. (g) Explain the term JavaScript URL. (2M)
Q.3. (d) Explain the term browser location and history in details. (4M)
Q.5. (b) Write a webpage that displays a form that contains an input for students rollno and names user is prompted
to enter the input student rollno and name and rollno becomes value of the cookie. (6M)
<html>
<body>
<form name="myform">
Student Name : <input type="text" name="Sname" id="name"><br>
Roll no. : <input type="number" name="Sroll" id="rollno"><br>
<input type="button" value="Store Cookie" onclick="storeCookie()">
<input type="button" value="Read Cookie" onclick="readCookie()">
</form>
<script>
function storeCookie(){
var rollNo=document.getElementById("rollno").value;
document.cookie=rollNo;
}
function readCookie(){
alert("Roll No. : "+document.cookie);
}
</script>
</body>
</html>