Css Final PDF
Css Final PDF
Certificate
Client Side Scripting languages (22519) for the academic year 2024 to
Seal of Institution
Program Outcomes (POs) to be achieved through Practical of this Course:-
PO 5.The engineer and society: Assess societal, health, safety, legal and
cultural issues and the consequent responsibilities relevant to practice in
field of Computer engineering.
Dated
Date of Date of Assessment
Sr.No Title of practical sign of Remarks
performance submission marks(25)
Teacher
Total
Introduction to java script
What is JavaScript?
<!DOCTYPE html>
<html>
<head>
<title>Arithmetic Operations</title>
</head>
<body bgcolor="yellow">
<script language="javascript"> var a = 36;
var b = 46;
Syntax
if (condition) {
// block of code to be executed if the condition is true
}
Syntax
if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
Syntax if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
Example :
<!DOCTYPE html>
<html>
<head>
<title>Weeks of Days</title>
</head>
<body bgcolor="Blue">
<h1>Use of Decision-Making Statement</h1>
<script type="text/javascript"> var day = 3;
switch (day) { case 1:
alert("Sunday"); break;
case 2:
alert("Monday"); break;
case 3:
alert("Tuesday"); break;
case 4:
alert("Wednesday"); break;
case 5:
alert("Thursday"); break;
case 6:
alert("Friday"); break;
case 7:
alert("Saturday");
break; default:
alert("Invalid day"); break;
}
</script>
</body>
</html>
OUTPUT :
2. do while: do while loop is similar to while loop with only difference that
it checks for condition after executing the statements, and therefore is
an example of Exit Control Loop.
Syntax:
do
{
statements.. }while (condition);
3. While loop
A while loop is a control flow statement that allows code to be executed
repeatedly based on a given Boolean condition. The while loop can be thought
of as a repeating if statement.
Syntax :
while (boolean condition)
{
loop statements...
}
Example :
<!DOCTYPE html>
<html>
<head>
<title>Prime or Not</title>
</head>
<body>
<script type="text/javascript">
var num = prompt("Enter a number");
var isPrime = true;
if (num <= 1) {
isP
} else {
for (var i = 2; i < num; i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
}
if (isPrime) {
alert(num + " is prime");
} else {
alert(num + " is not prime");
}
</script>
</body>
</html>
OUTPUT:
If we enter 5
If we enter 4
Array
What is an Array?
An array is a special variable, which can hold more than one value at a time.
Creating an Array
Using an array literal is the easiest way to create a JavaScript Array. Syntax: var
array_name = [item1, item2, ...];
Methods in Array
PUSH ():
The push () method is use to create a new element at the end of the array
POP ():
This method returns and removes the last element of the array
PUSH () Method :
Example:
<!DOCTYPE html>
<html>
<head>
<title>Push Method</title>
</head>
<body>
<script type="text/javascript"> var a = [];
a[0] = 10;
a[1] = 20;
a[2] = 30;
a[3] = 40;
a[4] = 50;
OUTPUT :
POP Method :
Example:
<!DOCTYPE html>
<html>
<head>
<title>Pop Method</title>
</head>
<body>
<script
type="text/javascript"
> var a = [];
a[0] = 10;
a[1] = 20;
a[2] = 30;
a[3] = 40;
a[4] = 50;
document.write("<h4>Calling pop()
method</h4>"); var poppedElement =
a.pop();
document.write("<p>Popped element: " + poppedElement + "</p>");
Function
<!DOCTYPE html>
<html>
<head>
<title>Calling Function with Arguments</title>
<script type="text/javascript"> function add(a, b) {
var c = a + b; document.write("Addition = " + c);
}
</script>
</head>
<body>
<h4>Passing Arguments to the Function</h4>
<script type="text/javascript"> var x = 10;
var y = 20; add(x, y);
</script>
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title>Calling Function without Arguments</title>
<script type="text/javascript"> function add() {
var a = 10; var b = 20; var c = a + b;
document.write("addition=" + c); // Use document.write to display output on
the web page
}
</script>
</head>
<body>
<h4>Passing Arguments to the Function</h4>
<script type="text/javascript"> add();
</script>
</body>
</html>
OUTPUT:
JavaScript Strings
• JavaScript Strings are used for storing and manipulating text.
• Strings in JavaScript can be enclosed within either “single quotes”,
“double quotes” or “backticks”:
var single_quoted = 'Single quoted string'; var double_quoted = "double-
quoted string"; var backticks = `backticks string`;
• Backticks, allow us to embed any expression into the string, by wrapping
it in ${…}: function product(x, y) {
return x * y;
}alert(`4 + 6 = ${product(4, 6)}.`); // 4 * 6 = 24
• Strings also can be created by using String’s fromCharCode() method.
String.fromCharCode(104,101,108,108,111) // "hello"
• String can also be created using String Object constructor along with
new keyword var objString = new String("I am a String object");
String length
• The length property has the string length.
• Note that str.length is a numeric property, not a function. There is no
need to add parenthesis after it.
String Methods
OUTPUT:
<!DOCTYPE html>
<html>
<head><title> username </title></head>
<body>
<form> Username: <br>
<input type="text" name="username"><br> Password: <br>
<input type="password" name="password"><br>
<input type="submit" value="Submit"><br>
</form>
</body>
</html>
OUTPUT:
HTML <form> Attributes
<!DOCTYPE html>
<html>
<head>
<title>web user registration </title>
<style> input[type="text"], input[type="password"], select {
border: 1px solid red; border-radius: 5px; padding: 5px; margin: 5px;
}form {
background-color: #f1f1f1; width: 40%;
padding: 20px;
}input[type="submit"] { border-radius: 5px; padding: 5px;
margin: 5px;
background-color: green; color: white;
font-size: 14;
} input[type="reset"] { border-radius: 5px;
padding: 5px; margin: 5px;
background-color: red;
<td>Full Name</td>
<td><input type="text" id="sname" /></td>
</tr>
<tr>
<td>Date of Birth</td>
<td>
<select name="date">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select><select name="month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select><select name="year">
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="gender" value="Male">Male</input>
OUTPUT:
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)
Practical 7- Create web page to implements Form Events.
Part I
<!DOCTYPE html>
<html>
<head>
<title>Form </title>
<script type="text/javascript"> function sayHello() { alert("Hello World!")
}
</script>
</head>
<body>
<p>Click the button to see result</p>
<form>
<input type="button" onclick="sayHello()" value="Say Hello" />
</form>
</body>
</html>
OUTPUT:
Common HTML Events :
onchange : An HTML element has been changed
onclick : The user clicks an HTML element
onmouseover : The user moves the mouse over an HTML element
onmouseout : The user moves the mouse away from an HTML element
onkeydown : The user pushes a keyboard key
onload : The browser has finished loading the page
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title> radiobutton </title>
<script type=”text/javascript”>
function changeColor(color)
{
var panel = document.getElementById('panel')
document.body.style.backgroundColor = color
panel.innerHTML = "Background color is set to: " + color.toUpperCase()
}
</script>
</head>
<body onload="changeColor('red')">
<p>Select option to change background color of page</p>
<form name="myform">
<input type="radio" name="color" value="red"
onchange="changeColor(this.value)" checked="false">RED<br />
<input type="radio" name="color" value="green"
onchange="changeColor(this.value)">GREEN<br />
<input type="radio" name="color" value="blue"
onchange="changeColor(this.value)">BLUE<br />
</form>
<p id="panel"></p>
</body>
</html>
OUTPUT :
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)
Practical 8- Create web page to implements Form Events.
Part II
Mouse Events
• Mouse events are used to capture the interactions made by user using
mouse.
• Such events may come not only from “mouse devices”, but are also from
other devices, such as phones and tablets.
<!DOCTYPE html>
<html>
<head>
<title>Mouse Events</title>
<script type=”text/javascript”> function init()
{
var panel = document.getElementById('panel') var btn =
document.getElementById('btn') btn.addEventListener("dblclick", dblClick)
btn.addEventListener("mousedown", mouseDown)
btn.addEventListener("mouseup", mouseUp)
btn.addEventListener("mouseover", mouseOver)
btn.addEventListener("mouseout", mouseOut)
}
function click()
{
panel.innerHTML += "Mouse clicked<br/>"
}
function dblClick()
{
panel.innerHTML += "Mouse double clicked<br/>"
}
function mouseDown()
{
panel.innerHTML += "Mouse down<br/>"
}
function mouseUp()
{
panel.innerHTML += "Mouse up<br/>"
}
function mouseOver()
{
panel.innerHTML += "Mouse over<br/>"
}
function mouseOut()
{
panel.innerHTML += "Mouse out<br/>"
}
function mouseMove()
{
panel.innerHTML += "Mouse moved<br/>"
}
</script>
</head>
<body onload="init()">
<input type="button" id="btn" value="Click Me" onclick="click()"
onmousemove="mouseMove"/>
<h3>Mouse events performed are</h3>
<p id="panel"></p>
</body>
</html>
OUTPUT :
Key Events
• The keyboard events are the events that occur when the user interacts
using the keyboard.
• The keydown events happens when a key is pressed down, and then
keyup when it’s released.
• The event.key property of the event object allows to get the character ,
while the event.code property of the event object allows to get the “physical
key code”.
• For instance, the same key Z can be pressed with or without Shift. That
gives us two different characters: lowercase z and uppercase Z.
• The event.key is exactly the character, and it will be different.
Example of KeyEvents :
<!DOCTYPE html>
<html>
<head>
<title>Key Events</title>
<script type =“text/javascript”> function init()
{
var panel = document.getElementById('panel')
document.addEventListener("keydown", keydown)
document.addEventListener("keypress", keypress)
document.addEventListener("keyup", keyup)
}
function keydown()
{
panel.innerHTML = "Key down<br/>"
}
function keypress(e)
{
var c = (window.event) ? e.keyCode : e.which panel.innerHTML += "Key
pressed: " + String.fromCharCode(c)
}
function keyup()
{
panel.innerHTML += "<br/>Key up"
}
</script>
</head>
<body onload="init()">
<p id="panel"></p>
</body>
</html>
OUTPUT :
1. Develop a JavaScript program for working with form events.
<!DOCTYPE html>
<html>
<head>
<title>Example: Working with form Events</title>
<style type="text/javascript"> p {
font-family: Verdana; background: #FA8B7C; color: #fff;
padding: 10px;
border: 4px solid #555;
}
</style>
</head>
<body>
<form>
<p>
<label for="name"> Name:
<input autofocus id="name" name="name" /></label>
</p>
<p>Client Side Scripting
Languages (22519)
Maharashtra State board of
Education
<label for="nick"> Nickname:
<input id="nick" name="nick" /></label>
</p><button type="submit">Submit</button>
</form><span id="output"></span></body><script>
var items =
document.getElementsByTagName("input")
; for (var i = 0; i < items.length; i++) {
items[i].onkeyup = keyboardEventHandler;
}function keyboardEventHandler(e) {
document.getElementById("output").innerHTML = "Key
pressed is: " + e.keyCode + " Char:" +
String.fromCharCode(e.keyCode);
}
</script>
</html>
OUTPUT:
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)
Practical 9- Develop a webpage using intrinsic java functions
Intrinsic JavaScript Functions
• An intrinsic function (or built-in function) is a function (subroutine)
available for use in a given programming language whose implementation is
handled specially by the compiler.
• “Intrinsic” is the way some authors refer to what other authors call
“built-in”.
• Those data types/objects/classes are always there regardless of what
environment you’re running in.
• JavaScript provides intrinsic (or “built-in”) objects. They are the Array,
Boolean, Date, Error, Function, Global, JSON, Math, Number, Object, RegExp,
and String objects.
• As you know JavaScript is an object oriented programming language, it
supports the concept of objects in the form of attributes.
• If an object attribute consists of function, then it is a method of that
object, or if an object attribute consists of values, then it is a property of that
object.
• For example,
var status = document.readyState;
readyState is a property of the document object which can contain values such
as “unintialized”, ”loading”, ”interactive”, ”complete” whereas,
document.write("Hello World");
write() is a method of the document object that writes the content “Hello
World” on the web page.
• JavaScript Built-in objects such as
Number
String
RegExp
Array
Math
Date
Boolean
eval()
• eval() is used to execute Javascript source code.
• It evaluates or executes the argument passed to it and generates output.
• For example
eval("var number=2;number=number+2;document.write(number)"); //4
Number()
• Number() method takes an object as an argument and converts it to the
corresponding number value.
• Return Nan (Not a Number) if the object passed cannot be converted to
a number
• For example
var obj1=new String("123"); var obj2=new Boolean("false"); var obj3=new
Boolean("true"); var obj4=new Date();
var obj5=new String("9191 9999");document.write(Number(obj1)); // 123
document.write(Number(obj2)); // 0
document.write(Number(obj3)); // 1
document.write(Number(obj4)); // 1342720050291
document.write(Number(obj5)); // NaN
String()
• String() function converts the object argument passed to it to a string
value.
• For example
document.write(new Boolean(0)); // false document.write(new Boolean(1)); //
true
document.write(new Date()); // Tue Jan 05 2021 13:28:00 GMT+0530
parseInt()
• parseInt() function takes string as a parameter and converts it to integer.
• For example
parseFloat()
• parseFloat() function takes a string as parameter and parses it to a
floating point number.
• For example document.write(parseFloat("15.26")); // 15.26
document.write(parseFloat("15 48 65")); // 15
document.write(parseFloat("this is 29")); // NaN document.write(pareFloat("
54 ")); // 54
1. An intrinsic function is often used to replace the Submit button and the
Reset button with your own graphical images, which are displayed on a
form in place of these buttons.
<!DOCTYPE html>
<html>
<head>
<title>Using Intrinsic JavaScript Functions</title>
</head>
<body>
<FORM name="contact" action="#" method="post">
<P>
First Name: <INPUT type="text" name="Fname"/> <BR> Last Name: <INPUT
type="text" name="Lname"/><BR> Email: <INPUT type="text"
name="Email"/><BR>
<img src="submit.jpg" onclick="javascript:document.forms.contact.submit()"/>
OUTPUT:
1. Write a JavaScript function to insert a string within a string at a
particular position (default is 1).
<!DOCTYPE html>
<html>
<head>
<title>Insert a string within a specific position in another string</title>
</head><body>
<script type=”text/javascript”>
function insert(main_string,
ins_string, pos) { if(typeof(pos)
== "undefined") {
pos = 0;
}
if(typeof(ins_string) ==
"undefined") {
ins_string = '';
}
return main_string.slice(0, pos) +
ins_string +
main_string.slice(pos);}
var main_string = "Welcome to JavaScript";
var ins_string = " the world of ";Client Side Scripting Languages (22519)
Maharashtra State board of Education
var pos = 10;
var final_string = insert(main_string, ins_string, pos);
document.write("Main String: <b>" + main_string + "</b><br/>");
document.write("String to insert: <b>" + ins_string
+ "</b><br/>"); document.write("Position of
string: <b>" + pos + "</b><br/>");
document.write("Final string: <b>" + final_string +
"</b>");
</script>
</body>
</html>
OUTPUT:
How It Works ?
Your server sends some data to the visitor's browser in the form of a cookie.
The browser may accept
the cookie. If it does, it is stored as a plain text record on the visitor's hard
drive. Now, when the visitor
arrives at another page on your site, the browser sends the same cookie to the
server for retrieval.
Once retrieved, your server knows/remembers what was stored earlier.
Cookies are a plain text data record of 5 variable-length fields −
• Expires − The date the cookie will expire. If this is blank, the cookie will
expire when the visitor quits the browser.
• Path − The path to the directory or web page that set the cookie. This
may be blank if you want to retrieve the cookie from any directory or page.
• Secure − If this field contains the word "secure", then the cookie may
only be retrieved with a secure server. If this field is blank, no such restriction
exists.
Storing Cookies
The simplest way to create a cookie is to assign a string value to the
document.cookie object, which
looks like this.
document.cookie = "key1 = value1;key2 = value2;expires = date";
Note − Cookie values may not include semicolons, commas, or whitespace. For
this reason, you may want to use the JavaScript escape() function to encode
the value before storing it in the cookie. If you do this, you will also have to use
the corresponding unescape() function when you read the cookie value.
Example
<!DOCTYPE html>
<html>
<head>
<title>cookie</title>
<script type = "text/javascript"> functionWriteCookie()
{ if(document.myform.customer. value == "" )
{
alert("Enter some value!"); return;
}
cookievalue = escape(document.myform.customer.value) + ";";
document.cookie = "name=" + cookievalue;
document.write ("Setting Cookies : " + "name=" + cookievalue );
}
</script>
</head>
<body>
<form name = "myform" >
Enter name: <input type = "text" name = "customer"/>
<input type = "button" value = "Set Cookie" onclick = "WriteCookie();"/>
</form>
</body>
</html>
OUTPUT:
You can access the cookie like this which will return all the cookies saved for
the current domain var x = document.cookie
Reading a cookie is just as simple as writing one, because the value of the
document.cookie object is the cookie. So you can use this string whenever you
want to access the cookie. The document.cookie string will keep a list of
name=value pairs separated by semicolons, where name is the name of a
cookie and value is its string value.You can use strings' split() function to break
a string into key and values
Example
<!DOCTYPE html>
<html>
<head>
<title>cookie 1</title>
<script type = "text/javascript"> functionReadCookie()
{ varallcookies = document.cookie;
OUTPUT:
Setting Cookies Expiry Date
You can extend the life of a cookie beyond the current browser session by
setting an expiration date and saving the expiry date within the cookie. This
can be done by setting the ‘expires’ attribute to a date and time.
Example
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript"> functionWriteCookie() {
var now = new Date(); now.setMonth(now.getMonth() + 1 );
cookievalue = escape(document.myform.customer.value) + ";"
OUTPUT:
Syntax
window.open(URL, name, specs, replace)
Parameter Description
URL Optional. Specifies the URL of the page to open. If no URL is
specified, a new window/tab with about:blank is opened
name Optional. Specifies the target attribute or the name of the
window. The following values are supported:
_blank - URL is loaded into a new window, or tab. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded name -
The name of the window
specs Optional. A comma-separated list of items, no whitespaces. The
following values are supported: channelmode=yes|no|1|0 Whether
or not to display the window in theater mode. Default is no. IE
only
directories=yes|no|1|0 Obsolete. Whether or not to add directory buttons.
Default is yes. IE
only
fullscreen=yes|no|1|0 Whether or not to display the browser in full-
screen mode. Default is no. A window in full-screen
mode must also be in theater mode. IE only
height=pixels The height of the window. Min. value is 100
left=pixels The left position of the window.
Negative values not allowed
location=yes|no|1|0 Whether or not to display the
address field. Opera only
menubar=yes|no|1|0 Whether or not to display the menu
bar resizable=yes|no|1|0 Whether or not the window is
resizable. IE only
scrollbars=yes|no|1|0 Whether or not to display scroll bars.
IE, Firefox & Opera only
status=yes|no|1|0 Whether or not to add a status bar
titlebar=yes|no|1|0 Whether or not to display the title
bar. Ignored unless the calling
application is an HTML Application or a trusted dialog box
toolbar=yes|no|1|0 Whether or not to display the
browser toolbar. IE and Firefox only
top=pixels The top position of the window.
Negative values not allowed
width=pixels The width of the window. Min. value
is 100
replace Optional. Specifies whether the URL creates a new entry or replaces
the current entry in the history list. The following values are supported:
true - URL replaces the current document in the history list false - URL creates
a new entry in the history list
Example:
<!DOCTYPE html>
<html>
<head><title>new browser</title>
<body>
<p>Click the button to open an about:blank page in a new browser window
that is 200px wide and 100px tall.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var myWindow = window.open("", "", "width=200,height=100");
}
</script>
</body>
</html>
OUTPUT:
Window.close()
This method is used to close the window which are opened by window.open()
method.
Syntax
window.close()
Window print() Method
The print() method prints the contents of the current window.The print()
method opens the Print Dialog Box, which lets the user to select preferred
printing options.
window.print();
• The resizeBy() method resizes a window by the specified amount,
relative to its current size. Syntax:
resizeBy(width, height)
• The moveBy() method moves a window a specified number of pixels
relative to its current coordinates.
Syntax:
window.moveBy(x, y)
• The resizeTo() method resizes a window to the specified width and
height. Syntax:
window.resizeTo(width, height)
• The scrollBy() method scrolls the document by the specified number of
pixels. Syntax window.scrollBy(xnum,
ynum)
OUTPUT:
Syntax
/pattern/modifiers;
Example
var patt = /w3schools/i; Example explained:
/w3schools/i is a regular expression. w3schools is a pattern (to be used in a
search).
i is a modifier (modifies the search to be case-insensitive).
Example
Use a string to do a search for "W3schools" in a string: var str = "Visit
W3Schools!";
var n = str.search("W3Schools");
Example
Quantifiers
Quantifier Description
n+ Matches any string that contains at least one n
n* Matches any string that contains zero or more occurrences of n n?
Matches any string that contains zero or one occurrences of n n{X}
Matches any string that contains a sequence of X n's
n{X,Y} Matches any string that contains a sequence of X to Y n's n{X,} Matches
any string that contains a sequence of at least X n's n$ Matches any string
with n at the end of it
^n Matches any string with n at the beginning of it
?=n Matches any string that is followed by a specific string n
?!n Matches any string that is not followed by a specific string n
Using test()
The following example searches a string for the character "e":
Example
var patt = /e/;
patt.test("The best things in life are free!");
Since there is an "e" in the string, the output of the code above will be:
true
You don't have to put the regular expression in a variable first. The two lines
above can be shortened to one:
/e/.test("The best things in life are free!");
Using exec()
The exec() method is a RegExp expression method.
It searches a string for a specified pattern, and returns the found text as an
object. If no match is found, it returns an empty (null) object.
The following example searches a string for the character "e": Example 1
/e/.exec("The best things in life are free!");
1. Develop a web page for validation of form fields using regular expressions.
We create a rollover effect that can change the color of its text using the style
attribute.
<p onmouseover=”this.style.color=’red'”
onmouseout=”this.style.color=’blue'”>
Move the mouse over this text to change its color to red. Move the mouse
away to change the text color to blue.
</p>
This example shows how to create rollover effect that involves text and
images. When the user places his or her mouse pointer over a book title, the
corresponding book image appears.
Example
<!DOCTYPE html>
<html>
<head>
<title>Rollover Effect</title>
</head>
<body>
<table>
<tbody>
<trvalign=”top”>
<td width=”50″>
<a><imgsrc=”vb2010book.jpg” name=”book”></a>
</td>
<td><img height=”1″ width=”10″></td>
<td><a onmouseover=”document.book.src=’vb2010book.jpg'”><b>Visual Basic
2010 Made Easy</b></a>
<br>
<a onmouseover=”document.book.src=’vb2008book.jpg'”><b>Visual Basic
2008 Made Easy</b></a>
<br>
<a onmouseover=”document.book.src=’vb6book.jpg'”><b>Visual Basic 6 Made
Easy</b></a>
<br>
</td>
</tr>
</tbody>
</table>
</body>
</html>
OUTPUT:
OUTPUT:
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)
Practical.No.14. Develop a webpage for implementing
Menus
The <select> element is used to create a drop-down list. The <option> tags
inside the <select> element define the available options in the list.
Example
<!DOCTYPE html>
<html>
<head>
<title>webpage </title>
</head>
<body>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</body>
</html>
OUTPUT:
Dynamically Changing menu
Example
<!DOCTYPE html>
<html>
<head>
<title>Dynamically changing menu </title>
<script language="javascript" type="text/javascript"> function
dynamicdropdown(listindex)
{
switch (listindex)
{
case "manual" :
document.getElementById("status").options[0]=new Option("Select
status",""); document.getElementById("status").options[1]=new
Option("OPEN","open"); document.getElementById("status").options[2]=new
Option("DELIVERED","delivered"); break;
case "online" :
document.getElementById("status").options[0]=new Option("Select
status",""); document.getElementById("status").options[1]=new
Option("OPEN","open"); document.getElementById("status").options[2]=new
Option("DELIVERED","delivered");
document.getElementById("status").options[3]=new
Option("SHIPPED","shipped"); break;
}
return true;
}
</script>
</head>
<title>Dynamic Drop Down List</title>
<body>
<div class="category_div" id="category_div">Source:
<select id="source" name="source" onchange="javascript:
dynamicdropdown(this.options[this.selectedIndex].value);">
<option value="">Select source</option>
<option value="manual">MANUAL</option>
<option value="online">ONLINE</option>
</select>
</div>
<div class="sub_category_div" id="sub_category_div">Status:
<script type="text/javascript" language="JavaScript"> document.write('<select
name="status" id="status"><option value="">Select
status</option></select>')
</script>
</div>
</body>
</html>
OUTPUT:
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)
Practical.No.15. Develop a webpage for implementing
Status bars and web page protection.
JavaScript gives you the ability to modify the status bar. For example it can be
useful to display information about a link, when the user moves his mouse
over it or you can display a small amount of information about the page the
user is on in the status bar. You can also trick people into clicking a link, so be
careful how you use it. If you play too many tricks on your visitors, they might
not come back.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Status Bar</title></head>
<body onLoad="window.status='Welcome!';return true">
</body>
</html>
onLoad tells the browser that as soon as your page finished loading, it will
display in your current window’s status bar (window.status) the message
“Welcome!”. The return true is necessary because without, it won’t work.
Status Bar Example:
<html>
<head>
<title>JavaScript Status Bar</title></head>
<body>
<a href="http://www.htmlcenter.com"
onMouseOver="window.status='HTMLcenter';return true"
onMouseOut="window.status='';return true"> HTMLcenter
</a>
</body>
</html>
OUTPUT:
Our second script listening shows how to modify the status bar using
onMouseOver and onMouseOut with links. When the user moves his mouse
over the link, it will display “HTMLcenter” in the status bar. When he moves his
mouse away from the link the status bar will display nothing.
You could also have another message displayed in the status bar, when the
user moves his mouse cursor away from the link. You have to change the
onMouseOut statement in the link to for example:
onMouseOut=”window.status=’You moved your cursor away from the
link.’;return true”.
Moving the message along the status bar
<!DOCTYPE html>
<html>
<head>
<title>Scrolling Text</tithttps://www.htmlcenter.com/blog/category/html5-2/le>
<script language="JavaScript"> var scrollPos = 0
var maxScroll = 100 var blanks = "”
function scrollText(text, milliseconds)
{ window.setInterval("displayText('"+text+"')", milliseconds)
}
function displayText(text)
{ window.defaultStatus = blanks + text
++scrollPos blanks += " "
if(scrollPos > maxScroll)
{scrollPos = 0 blanks = ""
}
}
</script>
</head>
<body onload="scrollText('Watch this text scroll!!!', 300)">
<p>Watch the text scroll at the bottom of this window!</p>
</body>
</html>
OUTPUT:
Protection web page
There are so many ways for users to get around this method of protection that
it shouldn't even really be considered a method of protecting your data.
Disable JavaScript. For this to work, JavaScript must be enabled on the
browser. View the source code and locate the image or text they want to copy
in the source code. Drag the image from the browser and drop it into the
desktop, file manager, or another open program. Disable the ability for user to
highlight text, copy, and paste it elsewhere.
Example
<!DOCTYPE html>
<html>
<head>
<title> Protection web page</title>
<script language="JavaScript"> function function2() {
alert("This image is copyrighted")
}
</script>
</head>
<body oncontextmenu="function2()">
<p>Right click in the image.</p>
<img oncontextmenu="function2()"
src="http://www.java2s.com/style/logo.png" alt="www.java2s.com"
width="99" height="76">
</body>
</html>
OUTPUT:
If you want to disable the context menu, add the following code to the <body>:
oncontextmenu="function2(); return false;"
Rotating banners ads comprises several banner images that constantly rotate
on a webpage at a fix time interval. You can create these banner images using
standard graphics tools.
Example:
<!DOCTYPE html>
<html>
<head>
<title> Creating Rotating Banner Ads </title>
<script language="Javascript">MyBanners=new
Array('banner1.jpg','banner2.jpg','banner3.jpg','banner4.jpg') banner=0
function ShowBanners()
{ if (document.images)
{ banner++
if (banner==MyBanners.length)
{banner=0} document.ChangeBanner.src=MyBanners[banner]
setTimeout("ShowBanners()",5000)
}
}
</script>
<body onload="ShowBanners()">
<center>
<img src="banner1.jpg" width="900" height="120" name="ChangeBanner"/>
</center>
</body>
</html>
OUTPUT:
Creating rotating banner images will provide the visitor to your webpage with
some basic information. However, if you want the visitor to get more
information by clicking on the banner images, you need to create rotating
banner ads that contain URL links.
<!DOCTYPE html>
<html>
<head>
<title>Creating Rotating Banner link</title>
<script language="Javascript">MyBanners=new
Array('banner1.jpg','banner2.jpg','banner3.jpg','banner4.jpg')
MyBannerLinks=new
Array('http://www.vbtutor.net/','http://www.excelvbatutor.com/','http://onli
nebizguide4you.com/','htt p://javascript-tutor.net/')
banner=0 function
ShowLinks(){ document.location.href="http://www."+MyBannerLinks[banner]
}function ShowBanners()
{ if (document.images)
{ banner++
if (banner==MyBanners.length)
{banner=0} document.ChangeBanner.src=MyBanners[banner]
setTimeout("ShowBanners()",5000)
}
}
</script>
<body onload="ShowBanners()">
<center>
<a href="javascript: ShowLinks()">
<img src="banner1.jpg" width="900" height="120"
name="ChangeBanner"/></a>
</center>
</body>
</html>
OUTPUT:
Slide Show
The JavaScript code for the slideshow is almost similar to the JavaScript code of
the rotating banners but it gives control to the user to choose the banner ads
he or she wants to see by clicking on the forward and backward buttons.
To create the JavaScript slideshow, first of all, you need to create a few banner
images using some graphics tools, or you can snap some photos with your
digital camera or your smartphone.
<!DOCTYPE html>
<html >
<head>
<title> Slide Show</title>
<script language=”Javascript”>
MySlides=new Array(‘banner1.jpg’,’banner2.jpg’,’banner3.jpg’,’banner4.jpg’)
Slide=0
function ShowSlides(SlideNumber){
OUTPUT:
Marks Obtained Dated Signed of
teacher
Process Product Total(50)
Related(35) Related(15)