You are on page 1of 3

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Cilent Side Scripting Subject Code: 22519


th
Semester: 5 Course: Computer Engineering
Laboratory No: L001B Name of Subject Teacher: Prof Pokharkar M.S.
Name of Student: Roll Id:

Experiment No: 15
Title of Experiment Develop web page for implementing Status bar and web page protection

Theory:

1. Status bar

• The status bar is located at the bottom of the browser window and is used to display a
short message to visitors to your web page.

• Though most web sites make use of status bar messages, some developers overlook this
feature.

Practical

<html>

<body>

<p>Look at the text in the statusbar.</p>

<p><b>Note:</b> This property does not work in default configuration of IE, Firefox,
Chrome, Safari or Opera 15+.</p>

<script>

window.status = "Some text in the status bar!!";

</script>

</body>

</html>

2. Protecting web page


2.1 Hiding JavaScript code

Page | 1
You can disable use of the right mouse button on your site so the visitor can't access the
View Source menu option on the context menu. This hides both your HTML code and
your JavaScript from the visitor.
2.1.1 Disabling right click
JavaScript methods are used to disable the right click on the page. The used methods are
listed below:
 HTML DOM addEventListener() Method: This method attaches an event handler to
the document.
Syntax:
document.addEventListener(event, function, useCapture)
Parameters:
 event: It is required parameter. It specifies the string which is name of the
event.
 function: It is required parameter. It specifies the function to run when the
event occurs. When the event occurs, an event object is passed as the first
parameter to the function. The type of the event object depends on the
defined event. For example, the “click” event is of MouseEvent object.
 useCapture: It is optional parameter. It specifies the boolean value that
whether the event should be executed in the capturing or in the bubbling
phase.
 true: It specifies that the event should execute in the capturing phase.
 false: It specifies that the event should execute in the bubbling phase.
 preventDefault() Event Method This method cancels the event if it can be cancelled,
meaning that it stops the default action that belongs to the event. For example- Clicking
on a “Submit” button, prevent it from submitting a form.

<html>
<body onload="disableRight()">
<H1>Right Click Disabled</H1>
<script>
function disableRight()
{
document.addEventListener('contextmenu',event=>event.preventDefault())
}
</script>
</body>
</html>

After Running this program, if we right click then context menu will not appeared that
Means right click is disabled

Page | 2
Grade and P1 (35M) P2 (15 M) Total ( 50 M) Dated Sign
Dated
Signature of
Teacher

Page | 3

You might also like