CSS Lec-40 Protecting Web Page - bfdd3b3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Course: Client Side Scripting, Prepared By: Atul Kabra, 9422279260

CSS Lecture-40
Topic: Protecting Web Page

Protecting Web Page :


We cannot entirely prevent user to view our web page, but we can take a
few steps to stop all but the best computer wizards from gaining access to
our javascript.

1) Hiding Source Code :


 Some times developer take code of a web page by using right-clicking on
web page and choosing “View Source” option from the context menu.
 We can place obstacles in the way of user by one of two ways to hide
source code.

Disabling Right Click Mouse Button :


 Disableing right mouse button on web site so the user can’t access the
view source menu option on the context menu. This hides both your
HTML code and your Javascript from the user.
 The preventDefault() method cancels the event if it is cancelable,
meaning that the default action that belongs to the event will not occur.
 For example, this can be useful when:
Clicking on a "Submit" button, prevent it from submitting a form
Clicking “Right click”, prevent the context menu.
Following program disable right click on web page, so that we hides source
code. (Disablerightclick.html)
<html>
<head>
<script>
window.onload = function(){
document.addEventListener("contextmenu",
function(e){
alert("Right click disables");

Course: Java Script, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Client Side Scripting, Prepared By: Atul Kabra, 9422279260

e.preventDefault();
});
}
</script>
</head>
<body>
<h1> Info Planet</h1>
</body>
</html>

2) Hiding Java Script :


 Instead of embedding Javascript code in HTML file, use the external (.JS)
file to write Javascript code and refer that external file in your webpage.
In this case if user would able to see the source code (HTML) of
webpage, but not the source code of Javascript.(.js).

 Other method is, You can store your Javascript code on your web server
instead of builing it into your web page. The browser calls the Javascript
code from the web server when it is needed by your web page. Using
this method, the Javascript code is not visible to the visitor, even if the
visitor views the source code for the web page.

Concealing Email Address :


 Some spammers creates programs called spam-bots or spam-crawler
that look for email address which is embedded inside the web pages.
 The majority of spam bots programs surf the pages in search of email
address in plain text such as [email protected]
 Solution to this problem is hide (conceal) your email address within web
page which is called Concealing email address.
 In following example rather than directly sending [email protected], we
conceal the email address using Javascript and when user click on a
button then a mailto dialog box appear.

Course: Java Script, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Client Side Scripting, Prepared By: Atul Kabra, 9422279260

(concealemail.html)
<html>
<head>
<script>
function makelink(){
var str='mailto:';
str = str+String.fromCharCode(97,98,99,64,103,109,97,105,10
8,46,99,111,109); //[email protected]
window.location.href=str;
}
</script>
</head>
<body>
<input type="button" value="Send" onclick="makelink()">
</body>
</html>

Framework of Javascript and its Application :


 Javascript framework is an application framework written in Javascript
where the programmers can manipulate the functions and use them for
their convenience. Javascript frameworks are a type of tool that makes
working with Javascript easier and smoother.

 Following are the most frequent and popular used framework used by
programmer to code the application as device responsive.

1) Angular JS :
a. AngularJS is one of the most powerful , efficient and open source
Javascript framework.

b. AngularJS is operated by the google and is basically implemented to


use for developing Single page application.

c. Every piece of application is easily testable.

d. It is fully extensible and works well with other libraries.

Course: Java Script, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260
Course: Client Side Scripting, Prepared By: Atul Kabra, 9422279260

2) ReactJS :
a. React framework that was originally created, and is maintained by
Facebook.
b. It is used to develop and operate the dynamic user interface of the
web page with high incoming traffic.
c. It can be used on client and server side.

3) NodeJS :
a. It is a server side Javascript run time environment, which works on
cross platform and is open-source.
b. It works in the Javascript Runtime environment and hence shows
similar properties of Java like threading, packages, forming of loops
c. It is very fast.

End Of Syllabus

Course: Java Script, Info Planet Programming Classes Prepared By: Atul Kabra, 9422279260

You might also like