CSS 06
CSS 06
Chapter-0 6 Menus,
Navigation and Web
Page Protection
3
▸ It enhance the readability of the text present on the web page, when user scroll over it.
▸ We can provide static message to browser window it will be displayed on the status bar.
4
Example:
<html>
<head>
<title>Static Status Message</title>
</head>
<body>
<script language = "JavaScript" type = "text/javascript">
window.status = "Welcome message in the status bar";
</script>
</body>
</html>
5
▸ For dynamically changing the status bar message we can use onMouseOver and
onMouseOut events.
▸ For this purpose, we can create one hyperlink and handle both onMouseOver and
onMouseOut events for changing the contents of status bar.
6
Example:
<html>
<head>
<title>Static Status Message</title>
</head>
<body>
<a href="../" onMouseOver = "window.status='Welcome';return true;"
onMouseOut="window.status=';return true;'">
Dynamically change status bar message
</a>
</body>
</html>
7
▸ For moving the message in the status bar we need to use loop and increment the current
position of the text one character in the loop.
Example:
<html>
<head>
<title>Sroll Status Message</title>
<script language = "JavaScript" type = "text/javascript">
let currentPosition = 0;
let targetPosition = 100;
let blanks = "";
function scrollFunction(){
window.setInterval(display,100);
}
function display(){
window.status = blanks+"Welcome Message";
++currentPosition;
blanks += " "
if(currentPosition>targetPosition){
currentPosition = 0;
blanks = "";
}
}
</head>
9
Example:
▸ It is a typical rectangular box for placing advertisement web-site(s) either above, below
or on sides of the web sites main content. Further, it will be linked to the advertisers own
web-site/pages.
Example:
<html>
<head>
<script language = "JavaScript" type = "text/javascript">
MyBanners = new Array("smiley.png", "divide.png", "plus.png", "minus.png","multipy.png");
bannerCount = 0;
function displayBanner(){
if(document.images){
bannerCount++;
if(bannerCount == MyBanners.length){
bannerCount = 0;
}
document.bannerChange.src = MyBanners[bannerCount];
setTimeout(displayBanner,1000);
}
}
</script>
</head>
12
Example:
▸ Therefore, whenever clients click on that the linked URL will open for clients.
▸ Banner are mostly used for advertisement purposes and therefore web pages are forwards
towards linked URL.
14
Example:
<html>
<head>
<script language = "JavaScript" type = "text/javascript">
function displayLink(){
document.location.href="http://www.gpnagar.ac.in";
}
</script>
</head>
<body>
<center>
<h1>Banner Linked Demonstration</h1>
<a href = "javascript: displayLink();">
<img src = "smiley.png" width = "500" height = "400" name = "bannerChange">
</a>
</center>
</body>
</html>
15
▸ In JavaScript we can create slide show of images using the Array of images.
▸ For creating slide show Firstly we created an array and stores images path into that
array for moving index by index.
▸ Further, we can create two buttons for moving forward and backward direction of slide
show.
16
Example:
<html>
<head>
<script language = "JavaScript" type = "text/javascript">
MySlides = new Array("smiley.png", "plus.png", "minus.png", "divide.png","multipy.png");
i=0
function moveSlide(slideNo){
i = i+slideNo;
if(i>MySlides.length-1){
i = 0;
}
if(i<0){
i = MySlides.length-1;
}
document.slideShow.src = MySlides[i]
}
</script>
</head>
17
Example:
<body>
<center>
<img src = "smiley.png" width = "500" height = "400" name = "slideShow">
<br><br>
<input type = "button" value = "Back" onClick = "moveSlide(-1);">
<input type = "button" value = "Forward" onClick = "moveSlide(1);">
</center>
</body>
</html>
18
▸ Therefore, if a menu is created for web pages it becomes very easy for visitors to select
an appropriate page.
▸ <option> tags can be inside <select> element to provide options in the list.
19
Example:
This file name Menu-1-
Creating-pulldown-menu.html
<html>
<head>
<script language = "JavaScript" type = "text/javascript">
function display(ele){
myPage = ele.options[ele.selectedIndex].value;
if(myPage != ""){
window.location = myPage;
}
}
</script>
</head>
20
Example:
<html> File Name: ns.html
Two extra files need to be created bdata.html
and ns.html <body>
<h1>Network Security</h1>
</body>
<body> </html>
<form name = "firstForm">
<select name = "myMenu" onChange = "display(this);">
<option value = "Menu-1-Creating-pulldown-menu.html">Select Research Area</option>
<option value="bdata.html">Big Data Analytics</option>
<option value="ns.html">Network Security</option>
</select>
</form>
</body> File Name: bdata.html
</html> <html>
<body>
<h1>Big data Analytics</h1>
</body>
</html>
21
▸ Example: We created two menus: (i) Name of students (ii) Boys/girls. When we select boys
name of student menus only contains boys names and when select girls then it only
contains girls names.
<html><head>
22<script language = "JavaScript" type = "text/javascript">
BoysList = new Array("Bhushan","Sandip","Prashant","Vivek");
GirlsList = new Array("Maahi","Shivadnya","Neha","Krutika");
function changeList(ch){
for(i=document.firstForm.Students.options.length-1;i>0;i--){
document.firstForm.Students.options.remove(i)
}
category = ch.options[ch.selectedIndex].value;
if(category != ""){
if(category=="1"){
for(i=1;i<=BoysList.length;i++){
document.firstForm.Students.options[i] = new Option(BoysList[i-1]);
}
}
if(category=="2"){
for(i=1;i<=GirlsList.length;i++){
document.firstForm.Students.options[i] = new Option(GirlsList[i-1]);
}
}
}
}
</script> </head>
23
Example:
<body>
<form name = "firstForm">
<select name = "lists" onChange = "changeList(this);">
<option value ="0">Class</option>
<option value="1">Boys</option>
<option value="2">Girls</option>
</select>
<select name = "Students">
<option value = "0">Students</option>
</select>
</form>
</body>
</html>
24
<html><head>
<script language = "JavaScript" type = "text/javascript">
function validateForm(){
let item = document.firstForm.myMenu.selectedIndex;
if(document.firstForm.myMenu.options[item].value==""){
alert("Please select class");
}
}
</script> </head>
25
Example:
<body>
<h1>***Form Menu Validation***</h1>
<form name = "firstForm">
<select name = "myMenu">
<option value = "">Select Class</option>
<option value = "1">TYCM</option>
<option value = "2">TYCO</option>
<option value = "3">SYCM</option>
<option value = "4">SYCO</option>
</select>
<input type = "submit" value = "Submit" onClick = "validateForm();">
</form> </body>
</html>
26
▸ Chain Select Menu: It is a one kind of Menu in which more than one menus
and options. Based on selection of first menu second menu dynamically
changes its options.
▸ Tab Menu: In the case on Tab Menu, when we click on one item, then its
description is visible.
28
▸ Context Menu: Context Menu is a menu that pops up when user click right
mouse button.
▸ Scrollable Menu: Sometimes there is limited space on the web page for displaying
all the menu options.
▸ Then in such a case, only limited menu options are displayed and remaining options
can be accessed by scrolling left or right.
▸ Side Bar Menu The side bar menu displays a menu on the side of web page.
Options on the menu can be linked to other web page or other menu options.
34
▸ It is possible to view the source code of website using right clicking and choosing
View Source Code option.
▸ It may be possible to copy our code for developing their website without taking
permission from website owner.
▸ For protecting website Disable mouse right click and store JavaScript code on
web server.