[go: up one dir, main page]

0% found this document useful (0 votes)
61 views3 pages

Practical No 15

Uploaded by

gaytrifarde
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)
61 views3 pages

Practical No 15

Uploaded by

gaytrifarde
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/ 3

Practical.No.15.

Develop a webpage for implementing Status bars and web


page protection.

Objective
Develop a webpage for implementing Status bars and web page protection.

Resource Used
- Computer with a text editor (e.g., Notepad++, Visual Studio Code)
- Web browser (e.g., Chrome, Firefox)

Theory

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.

Status Bar Example:

<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>
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”.

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.

Program :
Example

<html>
<head>
<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>

If you want to disable the context menu, add the following code to the <body>:
oncontextmenu="function2(); return false;"

Moving the message along the status bar

<html>
<head>
<title>Scrolling Text</title>
<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 :

Conclusion

You might also like