JavaScript by Ahmed Hamdy Eissa




JavaScript

Java
JavaScript and Java are very different languages.
JavaSript intended for nonprogrammers.
A Java program or Applet, can be loaded by HTML page and executed by the Java Interpreter, which is embedded into the browser. Java is a object-oriented complex language like C++ language.
Java is more than a programming language.
Java knocked down the walls between different various of personal computers, letting any program run without conversion on any kind of machine. It does things other languages does, but it does it better.

JavaScript
JavaScript is a object-oriented simple language intended for nonprogrammers to improve a Web page.
No development tools or compilers are required.
JavaScript can run on the browser without being compiled.
JavaScript source code can be placed directly within an HTML Web page or referenced in a separate file.
JavaScript source code is interpreted directly by the browser.

A JavaScript program within an HTML document:
<HTML>
<HEAD>
<TITLE>
Simple JavaScript Example by Ahmed Eissa </TITLE>
</HEAD>

<BODY>
<!-- Comment: HTML Text goes here Then, 3 lines script. --!>

<!-- window.alert("... "); display a message to the user in a screen dialog box. Click X to close it. --!>

<SCRIPT LANGUAGE="JavaScript">
document.write(" Here is my output. Hello! ")
window.alert("
Hello again!");
</Script>

</BODY>
</HTML>

CGI
The biggest difference between JavaScript and CGI is that CGI works on the server and JavaScript works on the user's own machine (the client). CGI is most useful for sending data to the server and sending server data back to the user.


What happens when you request a Web page from a server?
When you enter or select a URL:
1) The browser sends a Get request to the server.
2) The server sends back to the browser the Web page requested by the browser.
3) The browser sends a request for each graphic to the server.
4) The browser allocate space for graphics on your PC and display the Web page without waiting for the graphics arrival.
5) The remaining graphics are displayed as they received.

Processing the JavaScript:
1) After the server sends the HTML Web page the browser, and the browser received it.
2) The browser examines the HTML for <script> tag.
3) If a <script> tag is included the browser process the script.

The Process of a JavaScript depends on the Type of Script (Choose one):
1) If the script is included in the header, it is ignored unless another script calls it.
2) If the script is included directly in the body, its output will be included in the Web page.
3) If the script is an event handler for a specific part of the page, it will be processed only when the event happens.

JavaScript make a Web page Interactive:
JavaScript cannot access any data on the server or send data to the server. CGI is the easiest way to do this.
You can display the current date and time.
You can include information depends on the user's input.
You can also display the information you need to change in a separate frame.
Using JavaScript you can reload the page with different contents, but you can't change the text on a page.
You can change the images, and anything in a form element.

Your Source Code is Accessible:
You legally have a
copyright on any script you write, clearly state this in the source code and on the Web page that contains it. Place a copyright notice on important Web page.

Copyright © 2001 by Ahmed Eissa


How can you prevent the "HTML Source Code" for a document from being viewed?
<http://www.aw-soft.com/htmlguard.html> ("HTML Guard 2.0" - $15.00 - as of September 12, 2001)
If you want to prevent unauthorized copies of parts of your Internet sites you should have a look at HTML Guard. Among other features this software lets you encrypt your HTML source code and disable the right mouse button, text selection and the print function within a browser. Put an end to copying and modification of your HTML code, images and text by others thus protecting your copyright. While not offering absolute security, the combination of several tricks creates protection that certainly adds a great level of difficulty to circumvention. Once secured by HTML Guard, the files retain their original appearance and pages can be viewed in any common JavaScript enabled browser. (as of September 12, 2001 $15.00 )

Features:
-
the option to encrypt source code
- multifaceted options to block use of the right mouse button within browsers
- deactivate text selection and the print function within Internet Explorer
- protect entire directories or individual file lists
- secured files can be directly uploaded to a server using FTP
- the appearance of your pages remain completely unaltered (in the full version)
- the HTML pages remain viewable in every common JavaScript enabled browser
- file meta tags are not modified (important for search engine ranking)
- source code is optimized before encryption so the file size often decreases
- clear user interface offering full control and ease of use
- detailed help file
- low price ($15.00)

How secure are the methods used by "HTML Guard" ?
Let's be clear from the start: a reliable protection against copying of HTML pages and associated images does not exist. Unfortunately, "HTML Guard" cannot offer one hundred percent security either. However, the program uses a combination of multifaceted tricks that make copying much more difficult. The combination of different methods used, activates a protection that cannot be bypassed in the twinkling of an eye. The following table lists several of the protection features of "HTML Guard" and both advantages and drawbacks will be detailed, allowing you to reach your own conclusion.

1. Encode source code

By encrypting HTML source code you protect your web site from being easily stolen. The code becomes indecipherable to both the human eye and to HTML editors. To display an encoded page, the browser will decrypt the file's source code by executing a JavaScript. As the required decryption script is embedded into the source text, everyone is able to read it there as plain text. This is perhaps, like giving away the lock together with the key. Consequently anybody with JavaScript skills may analyze the script and get the original source text this way. However approximately 99 percent of all Internet users will certainly not be able to overcome this obstacle.

"Squeeze" source code (remove line feeds)

Removing unnecessary line feeds and blank characters leaves the source text looking extremely intricate and difficult to read, because the original structure of the code will be disturbed. Although manual editing is made much more difficult in this way, visual HTML editors can process the "squeezed" code without difficulty. Furthermore programs are available that are able to convert unstructured source code into clearly arranged HTML.

3. Insert blank lines

"HTML Guard" offers the option to add blank lines to the top and the end of your source code. This way it will appear to the viewer as if no source code is available. In order to intensify this effect you can enter an additional text such as "Source code not available" which will be shown at the top of the code. This method is a relatively simple diversion which a professional will certainly never be taken in by, because the source code can easily be reached by scrolling down the window. However, searching for the source text can be made significantly more difficult by increasing the number of blank lines. When using this option you should be aware that each additional empty line increases the file size by two bytes.

4. Lock the menu on the right mouse button

To prevent copying of images and links you can disable the right mouse button in the browser. Consequently the menu that normally appears after a right click will no longer be available. Unfortunately, this method currently only works with Internet Explorer (version 3.0 and above) and Netscape Navigator (3.0 or above). The majority of other available browsers, while in the minority, are unaffected by the right click protection and both images and links can be copied using the right mouse button. Furthermore you should consider that people do not like to be restricted too much and therefore a complete deactivation of the right mouse button might be an unpopular decision. That is why we include the option to "Disable right click on images" to allow you more flexibility.

5. Block text selection

Using the "Block text selection" option, you can stop visitors from selecting text, images or other elements in their browsers. This prevents people from copying your content to the clipboard. It should be noted that this method only works with Internet Explorer 4.0 and above. However, with Microsoft's Internet Explorer being so widely used, this option will prevent the majority of users from stealing your content.

6. Print only blank pages

Selecting the "Print only blank pages"option will prevent your visitors from printing your pages. Each print attempt will merely give out a blank page. Unfortunately this function is only available with Internet Explorer 5.0 or above. Be aware that no warning is given, so users may suspect a faulty printer or defective software.

Having read the above text, you will be aware that "HTML Guard" is no general purpose weapon for the protection of HTML pages. There is always a way to reach the source code and elements of a page, but how many people do you know that are good enough at JavaScript programming to bypass the source code protection? Would your friends not be impressed by a message like "Function not available" after right clicking an image? For the majority of Internet users, the protection mechanisms will be an obstacle that they cannot overcome without seeking outside help. In many Internet and Usenet forums the question about protection possibilities of HTML pages is a "Frequently Forbidden Question" (FFQ) that is answered unwillingly, if at all, and rarely without a cynical comment. The reason for this is that HTML is an open principle and almost every webmaster has gained experience by studying the source code of others. However, protecting text, images or scripts should not be considered as moral abjectly because this is the custom in other fields - and who would like to find content that had been created after spending enormous amounts of time, on somebody else's web site? Please remember that excessive use of protection and limitation could prevent visitors from returning to your web site.


Ahmed Hamdy Eissa's E-mail Address


Go to top of page

Ahmed's Home Page