6th Chapter of CSS
6th Chapter of CSS
6th Chapter of CSS
Conction scrolText(text,
chanq1ng.ht
mil iseconds) {
Image Rollover
@fiie| E/Javascript/6th%20unit/chan..
window.setlnterval('displayText("+text+"y", mil seconds)
function displayText(text) {
Apple
Pineapple
window.defaultStatus= blanks
++scrollPos
+ text
blanks +=""
wappiecoñapce if(scrollPos >maxScrol) {
S changnghtm
scrolPos=0
blanks
File E/Javascript/6th%20unit/chan...
Image Rollover
Agple
</script>
</head>
Pincapple <body onload="serollText(Welcome to JavaSeript, 300)"'>
we.eappieromipienaa.. <p>Watch the text scroll at the bottom of this window!</p>
In Program 6.1.2, if the mouse cursor <body>
cursor is moved to the "Pineapple' then moves to the 'Apple' it will display the link
associate with the 'apple' and if </html>
does not support the 'status'
property
link associated to the
pineapple is displayed in status bar. The modern mouse
links of the content in status bar.
of window, the status
message not displayed. The modern browser on browser
is Output:
show the
6.1.3 Moving the Message along the Status Bar X
Scrolling Text X
Tecakaowedyg
Client (MS8TE)
Menus Navigation and Web Page Protection Program6.2.1 .Write a JavaScript 6-6
code to create a enus Navigation and Web Page Protection
FClient Side Scripting Language (MSBTE)
6-5
solution:
simple banner.
DOCTYPEhtml>
S Scrolling Text
E:/Javascript/6th%20unit/scroll. chtml>
O File
<body>
bottom of this window!
Watch the text scroll at the <img src=
</body>
"p\Javascript\6th unit\fruits.jpg" all="custom html bannerl" "style="width:100%">
</html>
9 banner.html
9 Scrolling Text
E:/Javascript/6th9620unit/scrol. 0 File E:/Javascript/6th%20unit/bann..
O File |
Watch the text scroll at the bottom of this window!
Welcome to JavaScript.
In Program 6.1.3, statement window.setinterval("display Text("+text+")", milliseconds)' is used to set the scrolling
message. The setinterval()' function is used to set the message after milliseconds. The text' will send to the function
'display Text()' function, this function is called after milliseconds defihed in 'setinterval(} function. After calling the
to the top location of the
In Program 6.2.1, we have created a banner with the help of single image. The image is set
'displaytext(Y function, the statement window. defaultStatus = blanks + text is executed. In which the status of the using the statement <img src="E:\Vovascript|\6th unit\lfruits.jpg"
alt="custom_html_banner1"
window is changed by setting the new text to the 'defaultStatus' property of window object.
webpage by screen.
style="width:10O0%">. In this statement, we provide the width of the image to fit to the width of the
6.2 Banner
Program 6.2.2:Write a JavaScript code to change the images in banner.
rectangular area in webpage where image is placed for advertisement purpose is known as Banner. Banner can be <html>
placed anywhere in the webpage, horizontally on top and bottom or vertically at right and left side of the <head>
webpage.
6.2.1 Loading and Displaying the Banner Advertisement <script>
unitl\bannerl.jpg E:\Wavascript\\6h
How to load and display the banner advertisement ? Explain with example. banner_array=new Array(E:AJavascnpt\6th E:\Javascript\6th unit\banner4.jpg)
Q.
unit\banner2.jpg,'E:Javascriptl\6th unitl\banner3.jpg
To load and display the banner
advertisement, we placed an image in banner=0
particular advertiser. We can also provide the link to that image. When imagewebsite. That image is advertisement or
is clicked it will go to thè advertiser's
website. function DisplayBanners(){
if (document.images){
bannert+
tatiseS
Side
Client Scipung Language (MSBTEY
Navigation and Web Page Linking a Banner 6-8
Protection
Advertisement
Menus 6.2.2
to Menus Navigation and Web Page Protection
Client Side Scripting Language (MSBTE)
6-7
How to link a banner
URL
if (banner==banner array.lenglh)
1
Banner is mainly used
advertisement with
for
URL? Explain with
example.
banner. he user
shouldadvertisement
navigate to thepurpose. We need to provide the link
banner=0
image of
When user clicks on any image, user website the of to the banner. When user clicks the
navigate to that URL.advertiser. For this purpose
image. will
document.Change Banner.sre=banner array[banner] we provide the URL to each
6.2.3:Writea
Program JavaScript Code to link
setrTimeout("DisplayBanners()",5000) banner with the URL.
Solution:
IDOCTYPE html>
</script> <html>
File E:/Javascript/6th%20unit/bann..
In Program 6.2.2, we define an array of image links. It is possible to change the image of
banner automatically after
some specified time interval. We use 'set Timeout()' function to trigger the event which
change the image of banner. In
'setTimeout()' function we use a user defined function displayBanner()' and a time interval '5000
milliseconds. The
'displayFunction()' function will be called after 5 seconds of time interval. The statement
condition to check for the images in document. After that the index of array is 'document.images' is used in it
check the array index banner with the array size by using incremented by using banner+. Then We
the statement "banner=banner array.length' in if
the index is reached to
array size then the
condition.
index is set The statement
'document.ChangeBanner.src=banner_array[banner]'
name of image tag. By using
is used to change the image of banner.,
Here. 'ChangeBanner is the
property of that image we candocument.ChangeBanner
we access the image element in
set the link of image from the JavaScript. By using invoking Sre
image array.
PechKtege
echKaosledge Pusteatasns
ClientSide Scripting
Menus Navigation
and Web Page Language (MSBTE)
Client Side Scripting Language (MSBTE)
6-9
Protection document.location.href =link array[baniner 8-10
Menus Navigation and Web Page Protection
G Gcg'
httos w.o00gle com Gmail mages
</script>
cbodyonload="DisplayBanners()'>
<center>
ahref =
Limg
"Javascript:display page()">
Go gle src="'bannerl.jPg' width="100%" height='150"
<la>
<lcenter>
name="ChangeBanner'|>
<(body>
<html>
the linked URL webpage will be One
image to the URL If weclick the mage then
In Program 6.2.3, we link a banner statement ka href="https://www.google.com">'. Thus, if Output:
It is possible by using <a> tag and href attribute of HTML The
we click on banner image, then the Google web page will be opened. 9 banner rotate linkhtm!
’ C File
Program 6.2.4 :Write a JavaScript to link all the images in banner to URLS. E/lavascript/6th62Ounitbanner rotate_ linkhtmi
Solution:
<html>
<head> YAHOO!
<script>
banner_array=new Aray(E:\Javascript\6th unitl |google.jpg,E:\Javascript\6
unitl\gmai.jpg,"E:\Javascriptl\6th unitllyahoo.jpg,"E:|\Javascript|\|6th unit\Vacebook.jpg)
link array= new
Array('htps:/www.google.conm,htps/www.gmai.com, htps:/www.yahoo.com, 'htps://www.facebook.com")
banner=0
X
Yahoo india
function DisplayBanners){
httosjfinyahoa.com/?p=us
if (document.images){ FiBance Celebrity Movies Liestyle Moble
Mail News Cricket
banner++ t Hame
if (banner==banner array.length) { Q
banner=0
YAHOO!
Lifestyie Novies Celebrity
News Finance
Mail Cricket
document.ChangeBanner.sre=banner array[banner]
setTimeout("'DisplayBanners()",5000)
<DOCTYPE htmls
<html>
<head>
if(img<0){
img=img array.length-l;
PlC atj6ns
Client Side Scripting Language
Menus Navigation
and Web
Page (MSSBTE) 6-14
Client SideScripting Language (MSBTE)
6-13
created an image
with img' tag
and
the
two Protection
buttons. The
<option value="C++">C++</option>
<option value "JAVA">JAVA<<oplion>
Menus Navigation and Web Page Protection
images. We have will display next
In Program 6.3.1, we create a slide show of
slide show and the Next' button
on button clic .If
image in slide
'Previous' button will display the previous image in
image link from
array will be assign
incremented indey we
the 'Previous <option value:"JavaScript">Javascript<loption>
show. We have created an array of an image links. The using that can get the URI
incremnent by one. By index of the </select>
button is clicked, then the index of current imageisthe Next' Button is clicked, then the current image
displave URL 0s
of that index from array and display the image. If obtained by the array and s the <button onClick=
image.
decremented by one. By using that decremented index
6.4 Menus
theimage URL 0s
</body> -"GetSelectedItem(0:">Get Selected Item</buton>
</html>
<script>
function GetSelectedItem()
{
var ele =
var str =
document.getElementByld("select"):
ele.options[ele.selectedindex].value;
alert("The selected value is: "+str): In Program 6.4.1. we have created a 'pulldown' menu by using <select> tag and <option> tag. When we click on the
enu, the list of menu item willbe pulled down. We can select the option from the list. To get the access of the menu ie.
</script> elernent of HTML in JavaScriot the statement 'vor ele =document.getElementByld("'select "); is used. The getElementByld()
<body> function is used to get the access of the element of HTML by passing the id of the element in that function. After selecting
statement var str =
<select id="'select"> menu item, we can get the selected menu item value in JavaScript by using
'alert("The selected value
COptionslele. selectedindexl.value:. Then we can use that value to display by using statement
<option value="C">C</option> is: "+str);'.
changd dynamically.
opt.textContent = "'Subjects":
create the dynamically changing meno. select.appendChild(op);
Program 6.4.2 :Write a JavaScript code to
Solution : }
<!DOCTYPE html>
<html> </seript>
<head> </head>
<script> <body>
sy_subjects=new Array("0OP","CG""'DBMS","DSU" "'DTE"); Kselect id="mySelect" onchange="'myFunction(this)">
ty_subjects=new Array("AJP""STE","EST""OSY","CSS");
<option value="class"> Class </option>
function myFunction(sub) {
<option value="syco">SYCO</option>
var select = document.getElementByld("student");
<option value"yco">TYCO</option>
var s = select.options.length;
</select>
for(i=s;i>=0;i--){
<select id="student" name="student">
select.options.remove(i);
<option value="O">Subjects </opion>
</select>
var x =
document.getElementByld ('mySelect").value;
if(x=="yco") { </body>>
for(i=0;i<sy _subjects.length;it +){ </html>
opt = document.createElement("option");
Output :
opt.value= sy_subjects[i]:
dynamic_menu2.htmi
opt.textContent = sy_subjects[i];
O File E:/Javascript/menu/dynamic_m..
select.appendChild(opt);
Class. v Subjects v
Class
}else if(x=="tyco"){ SYCO
[TYCO
for(i=0;i<ty_subjects.length;i ++){
opt = document.createElement("'option"):
opt.value ty subjects[i);
TechKnouledee
PluEatiens
TechKnouledge
P u b t i atton
Client Side Scripun g Language (MSBTE)
8-18
document.-g etElementByld('mySelect'),value;
and Web var x = Menus Navigation and Web Page Protection
Menus Navigation Page Protection
6-17
ifx=="Select Subject"){
Client Side Scripting Language (MSBTE)
alert("Please select subjec."):
S dynamis_menu2.htnl }else{
E/Javascript/menu/dynamic_m.
document.
-getElementByld("ademo").innerHTML=
O File
Program 6.4.3 : Write a JavaScript code to validate the menu selection. Select Subject v
Submit
Solution:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var select =
document.getElementByLd('student): B TechKnowtedge
IchKnsatedyi
PuDIasns
ClientSide Scripting
Client Side Scripting Language (MSBTE) 6-19
Menus Navigation and
dWeb Page Protection Language (MSBTE
6-20
} Menus Navigation and Web Page
validate.html
</seript>
Protection
O File E/Javascript/menu/al1date.html
</head>
<body>
This page says
cbr> <br> <br>
Please select subject.
<p>Floating menu. Scroll
<select id="mySelect" Down.</p>
<option value=' 'sSubjtyle=e"ct'p'>oSelsit oenct:fixed"'
"Select >
<option value="OOP">00P</opion>
Koplion value ="CG"> CG</option>
Sbject</oplion>
In Program 6.4.3, we are validating the menu selection by usingJavaScript. The selected value can be store in the <option value=="DBMS">DBMS</option>
variable and then it compares with some condition to check whether the selection of menu item is proper or not. If the <optionvalue="DSU">>DSU</option>
proper option is selected then the value of that option will be displayed on screen. If proper value is not selected or meni
item is not selected then the alert message will be display as shown in above Tigure. <option value="DTE"'>DTE</opion>
</select>
6.4.4 Floating Menu
<br><br>
What is floating menu ? Explain with example. <input type="button' value="Submit'
How to create a floating menu ? Explain with example. <br> onclick='yFunction(0'>
When user scrolls the webpage, sometimes we needa menu to stick to the screen for particular operation. The menu <p id="'demo"> </p>
which is fixed while scrolling the webpage is known as floating menu. A floating menu can be
created by setting the style <br> <br> <br> <br> <br> <br> <br> <br>
position of that menu fixed. Following example shows the floating menu on webpage.
</body>
Program 6.4,4:Write a JavaScript to create floating menu.
</html>
Solution:
<!DOCTYPE html> Output:
<html>
<head> floating.htmi
<seript> ’C File E/lavascript/menu/floating.html
function myFunction() {
var select=document.getElementByld('student"):
var x =
document.getElementByld('mySelect").value;
if(x=="Select Subject"){ Floating menu. Seroll Down.
alert("Please select subject.");
}else{ Select Subject
Tech Kpouledgé
Pubt atons
Menus Navigation and
Web Page Clent Side Scripting
Client Side Scripting Language (MSBIE) 6-21
Proleclon 64.6 TabMenu Language (MSBTE)
X
622
flosting.htm Menus Navigation and Web Page
What is Tab menu?
O File /Javascript'menu/floating.html Protection
Tab menu contain the
one of
Floating menu. Scroll Down. atab-head
thenthe
content relatedmoreto tthatab-head
replacethe previous content on
likea
tab button. Each tab
tab-head click then thebetabdisolmenuaved.is Mwe contwantainsmgreseparatthane oneContentpageto display.
wil
If we click on
like
the best content which will
Home option.
Submit
About usl Contact
Select Subject v
sliding menu.
Client Side Scriptingg Language(MSBTE)
Menus Navigation and Web 6-24
6-23
Page Protecion
Language (MSBTE) Menus Navigation and Web Page Protection
Client Side Scripting Product Services
X he Contact Product
Home Home Mobe
About Us
Product page content...
uptops
Product lage content...
Services
Services
Home page content...
Contact Contact
Fig. 6.4.6
Fig. 6.4.4
As shown in the Fig. 6.4.6,the menu can be
screen. If we click on +hie t listbelow the menu expanded. If we click on afoldable
clicked. If we click again then the tree menu it will display the sub menu
icon is displayed on left side of the first sub menu will be
As shown in Fig. 6.4.4, the sliding menu hidden i.e. folded.
and display as shown in second screen. It may contain more than one sub men, E 6.4.11 Context Menu
menu will slide from left to right
product +he
that sub menu will be displayed. As we click on
click on any sub menu then the content related to
menu will hide by sliding from right to left. What is context menu?
content willbe displayed and the
6.4.9 Highlighted Menu ona webpage if we click a right button of
mouse then the context menu will be
. click of mouse and the
position of menu is depend on the location where the mousedisplayed. The will be displayed on
is clicked.
Q. What is highlighted menu?
Cut
menuitem, the menu
The highlighted menu can be created by-mouse over effect. As user moves the mOUse to any Copy
as bold, etc. The
will be highlighted by using special effects such as background color change or making the font style Paste Options:
highlighted menu is used to make a confirmation that the user is going to choose a proper menu item.
X
Home Font...
About U
Us
Paragraph...
Product
Services Highlighted Bullets
Contact Menu
Numbering
A Styles
Hyperiink..
A menu
which contain sub menu and the sub menu
contain the sub menuthen the hierarchy like 6.4.12 Scrollable Menu
Created. The menu can be fold by hiding the sub menus and tree oT mee
unfold by displaving the submenu of a mnenu is
foldable tree menu, known What is scrollable menu?
screen is called as scrollable menu. If there are
can be scrolled to
display limited item on
The In which items screen then we can use the scrollable menu.
many menumenuneed to be displaved on screen, but all menus are not fit onthe
Teceg
Client Side. Scripting
Menus Navigation and Web
Language (MSBTE)
Client Side Scripting Language (MSBTE) 6-25
Page Protection 651 Hiding Your Code 6-26
Menus Navigation and Web Page
ProductServces code of Protection
Home| About Us| The source the
cimoly viewwebpage
can be
the
webpagecan
the source code viofewed by clicking right mouse
IAbout Us | Product | ServcesCllents
source code
ofthe
webpage by disabling the rightthe webpage. Viewing sourcebuttoncodeonby the webpage. Anyone who visits to
buttonin JavaScript.
Hiding source code is mouse dick on users is not safe, We can hide the
Disabling the Right
protecting the source codewebpage.
by
We write the code to disabie the right
viewing
mouse
other users.
Product |Servces lclients Contact
6.5.2
Mouse Button
The source code of the
Fig. 6.4.8 iewing source Code
webpage of some websites can be
source'. By we can find out how the viewed by right clicking selecting the option 'view
and
webpage. It is not weboage is
Ihe above Fig. 6.4.8, the sCrollable menu. There are two arrows which scrolls the
menu. IT we click on left arrow tho their own
see the
secure to display asource code to users. created. anvone can use that source code to create
menuitem from ons the user cannot We can disable the right cick of
one menu of left side will be bide and the and one new menu is added to right side. It just scrolls the source code eof the mouse button. Thus
side to another.
webpage.
Program 6.5.1 : Wite aJavaScript code to
disable the right moUse cdlick.
6.4.13 Side Bar Menu Solution:
Product
<script>
Product Mobiles:
Services Services Laptops document.addEventListener('contextmenu,event=>event. preventDefault));
Department
</script>
Department
Contact Contact
<head>
<body>
Product Mobiles. <h3><p> Disabling thee right click of mose button.</p></h3>
Services Laptops Asus <body>
Department Lenovo </html>
Contact HP
Output :
Fig. 6.4.9 right.htm!
In Fig. 6,4.9, the side bar menu is shown. If we click a menu :
item 'Product then the side menu itenms will be displayed. (-’ C File E/Javascript/rollover/menu/ig..
again if we click on the side sub menu item Laptops, then the sub
menu item of "Laptops' will|be displayed.
mouse button.
6.5 Protecting the Webpage Disablingthee right click of
TecdKaaiedgë
TechKuoleu
Client Side Scripting
Client Side Scripting Language 6-27
Menus Navigation and Web Page Language (MSBTE)
In
Program 6.5.1,
(MSBTE)
disabled the right mouse click by using Protecion output: 6-28
we
´document.addEventlistener('contextmenu'
which prevent to perform any action on right click. On right click, the context menu is used to open, and we
statement
,event=>event.preventDefault();. We add the even listener on the document.
)
Menus Navigation and Web Page
Protection
prevent to open that context menu.
need to Protecting Email address from u X
6.5.3 Concealing email Address O File
Concealing email address means to hide email address from unauthorized user. If we are working with the javascr. @example.com
doaress and we don't want to show email address to the user, then we can hide the email address by using JavaScriot email
Program 6.5.2 : Write a JavaScript code to hide the email address.
Solution:
i Program 6.5.2, we have create a
<!DOCTYPE btml>
<html>
ll address to hide the some charactersJavaScript
in email
function hide emaill). The function
contains the code to
e the ' dot to address. We use the string function to split the convert the
repave the email address email string and then
<head> nrotect the email address by using Javascriot.characters. The changed email address is displayed to the user. Thus we can
<title> Protecting Email address from unauthorised user</title>
<script>
6.6 Frameworks of JavaScript and its Application
hide email = function (email address) { What are the JavaScript frameworks?
var avg, splitted, partl, part2; What are the applications of the JavaScript Framework?
splitted = email address.split("@": A JavaScript framework is an application framework which is written in JavaScript. JavaScript
frameworks are
partl = splitted[0}: collections of JavaScript libraries which provide the predefined code or functions to the developer. It performs the general
avg = partl.length/2; programming that JavaScript do and many more with less lines of code. There are various JavaScript frameworks are
partl available. Each framework has different work flow. An entire application is based on the framework. The framework
partl.substring(0, (partl.length avg)): designs the complete application. in framework, User need not call the predefined library functions instead the framework
part2 = splitted[1]; itself call the functions in specific way. Some of the framework such as AngularJS folows the Model-View-Controller design
improve the code quality. Some of the
return partl + "..@" + part2; patern to separate the complex code and to make easy the development and
}; examples of JavaScript frameworks are Angular!S, ReactJS, Meteor.JS, Ember.JS, etc.
JavaScript frameworks are used in web development as well as in
Each Framework has wide range of applications.
alert(hide_email('javascript_2019@example.com"):
</script> yorid mobile app development, It improves
the code
by
quality. The development of entire application is
developer. The reactjs is used in
based on the
react-native mobile application
ramework, where less code is required to write Frameworks reduce the code cómplexity.
</head> web application development.
development. Angular JS is used in single page
<body>
<h3><p> Email Address is Protected.</p></h3>
</body>
</html>
TechKaestedee
Pal4catibas