0% found this document useful (0 votes)
16 views

Exp 16

The document discusses using status bars and hiding code and content from users on web pages. It provides theory on building static and dynamic status bar messages. It then gives examples of JavaScript programs to implement a static status bar message, change the status bar message on mouseover, scroll text in the status bar, disable right click to view source, hide JavaScript by linking to an external file, and conceal email addresses. The conclusion indicates all programs worked as expected.

Uploaded by

34 Vedant Lad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Exp 16

The document discusses using status bars and hiding code and content from users on web pages. It provides theory on building static and dynamic status bar messages. It then gives examples of JavaScript programs to implement a static status bar message, change the status bar message on mouseover, scroll text in the status bar, disable right click to view source, hide JavaScript by linking to an external file, and conceal email addresses. The conclusion indicates all programs worked as expected.

Uploaded by

34 Vedant Lad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment No.

16
Aim: Develop a web page for implementing a Status bars and Web page protection.
Theory:
Status Bar:
The status bar is located at the bottom of the browser window and is used to display a short message to
visitors on a web page. Developers who are clever to utilize the status bar employ various techniques to
incorporate the status bar in the design of their web page. Some developers display a message on the status
bar when the web page first opens. Other developers might change the message to reflect whatever the
visitor is doing on the web page. For example, if a user is filling registration form then status bar will display
a text as ‘User is on form filling section’.

Building a Static Message:


A static message appears when the web page opens and remains on the status bar until the web page is
closed. The content of the status bar is the value of the window object's status property.
To display a message on the status bar, assign the message to the status property of the window object.
Example:-
window.status= 'You are on home page';

One can make the status bar message come alive by telling the visitor something about objects the visitor
points to on the web page. The message on the status bar changes as the visitor moves the mouse cursor over
objects on the page. This can be done by using rollover to signal the browser when a different message
should be displayed. An onmouseover event is generated whenever the visitor moves the mouse cursor over
an object on the web page. The browser executes the statement the onmouseover property when an
onmouseover event occurs.

Hiding Your Code from user:


Anyone can access the code of a web page or two by right-clicking and choosing View source from the
context menu. The source code for a web page—including JavaScript—is stored in the cache, the part of
computer memory where the browser stores web pages that were requested by the visitor. A visitor can
access the cache and thereby gain access to the web page source code.
1. A developer can disable use of the right mouse button on site so the visitor can't access the View Source
menu option on the context menu. This will hide both HTML code and JavaScript from the visitor.
2. In addition, developer can store JavaScript on his web server instead of building it into web page. The
browser calls the JavaScript from the web server when it is needed by the web page. Using this method, the
JavaScript isn't visible to the visitor, even if the visitor views the source code for the web page.

Programs:
1. To display a static message on status bar
<html>
<head>
<script type="text/javascript">
window.status='Welcome to Home Page';
</script>
</head>
<body>
<h1>Hello welcome to JavaScript</h1>
</body>
</html>

2. To change the message in status bar with text rollover


<html>
<head>
<script type="text/javascript">
window.status="You are in home page"
function displaystatus(no)
{
if(no==1)
{
window.status="You are in CSS"
}
if(no==2)
{
window.status="You are in AJP"
}
if(no==3)
{
window.status="You are in OSY"
}
}
</script>
</head>
<body>
hi welcome
<a onmouseover="displaystatus(1)">CSS</a>
<a onmouseover="displaystatus(2)">AJP</a>
<a onmouseover="displaystatus(3)">OSY</a>
</body>
</html>

3. Moving the Message Along the Status Bar


<html>
<head>
<title>Scrolling Text</title>
<script language="JavaScript">
var scrollPos = 0; // initial position to start status bar
var maxScroll = 100; // maximum allowed position
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('Welcome to polytechnic !!!', 300)">
<p>Watch the text scroll at the bottom of this window!</p>
</body>
</html>

4. Disable Right Mouse Button :


<html>
<head>
<title>Lockout Right Mouse Button</title>
<script type="text/javaScript">
function BreakInDetected()
{
alert('Security Violation')
return false
}
document.oncontextmenu=new Function("BreakInDetected();return false") // disable the context menu
</script>
</head>
<body>
<h1>hello</h1>
</body>
</html>

5. Hiding Your JavaScript

Script: Save below code with script1.js


function msg()
{
alert("Hello Javatpoint");
}
Program :
<html>
<head>
<script type="text/javascript" src="script1.js">
</script>
</head>
<body>
<p>Welcome to JavaScript</p>
<form>
<input type="button" value="click" onclick="msg()"/>
</form>
</body>
</html>

6. Concealing Your E-mail Address


<html>
<head>
<title>Conceal Email Address</title>
<script language=JavaScript>
function CreateEmailAddress()
{
var x = 'BobSmith&smith*c_o_m' ;
var y = 'mai'
var z = 'lto'
var s = '?subject=Customer Inquiry'
x = x.replace('&','@')
x = x.replace('*','.')
x = x.replace('_','')
x = x.replace('_','')
var b = y + z +':'+ x + s
window.location=b
}
</script>
</head>
<body>
<input type="button" value="Help" onclick="CreateEmailAddress()">
</body>
</html>

Conclusion:
With all the concepts based on Status bar and web page protection , successfully executed all programs with
correct output.

You might also like