BREAKING NEWS

Blogger Security

Css

Javascript

Friday, May 9, 2014

Introduction About JavaScript

JavaScript is a programming language that can be embedded into HTML as well as PHP but run javascript on the client side.


For example, the clock is displayed on a page that updates itself to show the current time on the user's computer. JavaScript design is influenced by many programming languages​​, including C, but is intended to be used by non-programmers. JavaScript is not based on or related to Java, this is a common misconception. JavaScript is often included in the HTML file or a link from an HTML file and run locally by a web browser. This means that the server is free to do something else rather than processing instructions for each client. This has made JavaScript a more popular choice than the language that requires the server to do the processing.

History of Javascript

JavaScript was first developed by Brendan Eich of Netscape under the name Mocha, which was later renamed to LiveScript, and finally to JavaScript. 
Previous Navigator supports Java can be used to further the non-Java programmers. Is developed programming language named LiveScript to accommodate it. Programming language is what ultimately evolved and given the name JavaScript, although there is no relationship between the Java language to JavaScript. 
JavaScript can be used for many purposes, for example to create a rollover effect both in image and text, and is also important to make AJAX. [6] JavaScript is the language used for AJAX 

Some example uses are :

  • rotating or scrolling text. 
    1. Rotating or scrolling text.
    2. Made part of a form of visible or not visible. For example, in an order form, if the user ticks the checkbox "delivered to a different address", an extra part with a text box with streetname delivery, number, and places can be made visible. 
    3. Drop down menu. 
    4. Take additional information from the server (Ajax) to partially refresh the page. 
    5. Validate user input on a form. 
    6. Calculations without the need to go back to the server. 
    7. Determine the type of browser.
    obviously some of the information from certain types of users, such as email addresses from bot. 

    Server-side language such as PHP or Perl is the best way to modify the page before loading, although there are some cases server-JavaScript (SJS). Not all browsers have JavaScript interpreter (such as text-only Lynx browser), or running the latest version. In addition, some users turn off JavaScript capabilities with options. Generally, a web page should use JavaScript to enhance the user experience, not depend on it. It is often referred to as graceful degradation (ie if the user has disabled JavaScript, the page should always still load, presents the same information but without the additional functionality provided by the JavaScript.)

    Relationship to Java

    Despite the similar names , Java and JavaScript , has little to do apart from the syntax between the two languages ​​. In fact, they were developed by two completely different companies , with different goals and ideas : Netscape developed the JavaScript and Java Sun Microsystems develops . Only two names are confusing for people who do not know .

    JavaScript can be interpreted by the browser that is most directly and quickly , while requiring a separate Java " Java Virtual Machine " has to start before running . JavaScript and Java are both using similar syntax ( based on the C language ) but the commands used many very different . There are also technical differences . Java is a statically typed language that requires declaration of all variables and their types ( eg integer , string or boolean ) . Instead , Javascript is " loosely " typed language , allows variables to be used without prior declaration .

    For example , comparing two methods of writing to the display ( page ) 
    .
    In Java , to write " Hello world ! " , Code will read : System.out.println ( " Hello World!" ) ;
    Whereas in JavaScript ( in the browser ) , will say : document.write ( " Hello World!" ) ;

    For more details of writing javascript example below ,

    Writing JavaScript

    JavaScript code is usually written in the form of a function that is placed in the open <head> with tags
    <script type=”teks/javascript”>.
    <script type=”teks/javascript”>
    alert(“Halo Dunia!”);
    </script>
    JavaScript code can also be placed in a separate file with extension. Js (short for JavaScript). To call JavaScript code contained in the file itself, in the early part <head> file name must be specified in advance. Js is using code like the following example: 
    <script type=”teks/javascript” src=”alamat.js”>
    </script>
    Script in the head

    This script will be executed when called (usually a function) or a trigger is invoked based on certain events. The placement of the script in the head will ensure the scripts are loaded before use (invoked).
    <html>
    <head>
    <script type=”teks/javascript”>
    …
    </script>
    </head>
    </html>
    Script on the Body

    This script is executed when the page is loaded up on the <body>. When placing the script in the <body> means between content and JavaScript into one piece.
    <html>
    <head>
    </head>
    <body>
    <script type=”teks/javascript”>
    …
    </script>
    </body>
    </html>
    Number of JavaScript in <head> and <body> placed on the document is not limited. 
    external JavaScript 
    Sometimes there is a desire to run JavaScript in the same number of times on different pages, but do not want to be preoccupied if desired rewrite the script in each page. JavaScript can then be written in the file externally. So, between the HTML document and JavaScript are separated, then the file is called from the HTML document. The JavaScript file is saved with the extension. Js. 
    JavaScript: js / xxx.js document.write ("This message appears when the page is loaded"); 
    To use an external JavaScript (. Js) used the attribute "src" on <script> tag on the HTML page.
    <html>
    <head>
    </head>
    <body>
    <script src=”xxx.js”>
    </script>
    <p>Script di atas berada di berkas “xx.js” (eksternal) </p>
    </body>
    </html>
     That's what I can say after reading from several sources, may be useful.

    Post a Comment

     
    Copyright © 2013 Tips & Trik Blog
    Powered byBlogger