1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript What is JavaScript?

Discussion in 'Web Development' started by gilbertsavier, Aug 4, 2009.

  1. gilbertsavier

    gilbertsavier New Member

    Hello,
    JavaScript is a compact, object-based scripting language for Web pages. JavaScript code embedded into your HTML pages can enhance them with many interesting elements, from swapping images when you move a cursor over them, to multi-level drop-down menus.

    You can create really sophisticated and almost application-like pages with the help of JavaScript. You don't need any special software other than a text editor and a Web browser, and you don't need access to a Web server. You can create and test all your JavaScript code right on your own computer.

    JavaScript and Java
    Although the names are almost the same, JavaScript isn't the same as Java. These are two different techniques for Internet programming. Java is a real programming language, and you can create real programs with it.

    JavaScript is a scripting language. You could even say that JavaScript is rather an extension to HTML than a separate computer language. It's so tightly integrated with HTML that you could call it "JavaScript markup language." JavaScript coders don't care too much about real programming, they just make different nice effects by inserting small JavaScript code fragments into their Web pages.

    The drawbacks of JavaScript
    Right now the biggest problem is the imperfect JavaScript implementations that today's browsers offer. Although all major browsers that are version 3.0 or higher include JavaScript support, they deal with JavaScript differently.

    In fact, different versions of the same browser handle JavaScript differently. This makes it difficult to create a complicated JavaScript code that work across all browsers. So always check your pages on as many different browsers (and even platforms) as possible.

    What do JavaScript code look like?
    Like HTML, JavaScript is just text that can be typed into a text editor. Its code is embedded in HTML within a <SCRIPT> tag. Some old browsers don't understand this tag. To prevent them from treating your JavaScript as HTML, always use this trick involving HTML comments...

    Code:
    <script type="text/javascript">
    <!-- hide JavaScript code from old browsers
    YOUR SCRIPT HERE
    // end the hiding comment -->
    </script>


    Here's an example of JavaScript code that prints current date in the top right corner of your Web page...
    Code:
    <html>
    <head>
    <script type="text/javascript">
    <!--
    function PrintDate() {
    today = new Date();
    document.write('Date: ', today.getMonth()+1, '/', today.getDate(), '/', today.getYear());
    }
    //-->
    </script>
    </head>

    <body>
    <p align="right">
    <script type="text/javascript">
    <!--
    PrintDate();
    //-->
    </script>
    </p>
    THE REST OF YOUR PAGE.
    </body>
    </html>


    Thanks & regards
    Lokananth
     
  2. scottamber

    scottamber New Member

    Javascript is a programming language that is used to make web pages interactive. It runs on your visitor's computer and so does not require constant downloads from your web site.



    Regards...


    Scott....

     
  3. maryjohn

    maryjohn New Member

    Hello Programmer..

    Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems. JavaScript was created by the fine people at Netscape. JavaScript is a distant cousin of Java. It is also an OOP language. Many of their programming structures are similar. However, JavaScript contains a much smaller and simpler set of commands than does Java. It is easier for the average weekend warrior to understand.

    The main difference is that Java can stand on its own while JavaScript must be placed inside an HTML document to function. Java is a much larger and more complicated language that creates "standalone" applications. A Java "applet" (so-called because it is a little application) is a fully contained program. JavaScript is text that is fed into a browser that can read it and then is enacted by the browser.

    Java must be compiled into what is known as a "machine language" before it can be run on the Web.
    JavaScript is text-based. You write it to an HTML document and it is run through a browser. You can alter it after it runs and run it again and again. Once the Java is compiled, it is set. Sure, you can go back to the original text and alter it, but then you need to compile again.
    Java applets run independent of the HTML document that is calling for them.

    The delivery of the applet is done through a download. The HTML document calls for the application, it downloads to the user's cache, and waits to run. JavaScript is wholly reliant on the browser to understand it and make it come to life.

    So, what are the benefits of using one over the other? There are several. If you can understand Java, it is amazingly versatile. Because of the size and structure of the language, it can be used to create anything from small Web page events to entire databases to full browsers.

    JavaScript's main benefit is that it can be understood by the common human. It is much easier and more robust than Java. It allows for fast creation of Web page events. Many JavaScript commands are what are known as Event Handlers: They can be embedded right into existing HTML commands. JavaScript is a little more forgiving than Java. It allows more freedom in the creation of objects.

    Java is very rigid and requires all items to be denoted and spelled out. JavaScript allows you to call on an item that already exists, like the status bar or the browser itself, and play with just that part. JavaScript is geared to Web pages. Java is geared toward where it is needed most at the time.

    ;)
     
  4. jaypaul0001

    jaypaul0001 New Member

    ya, very easy, it is an object oriented scripting language.
     
  5. bradstyris

    bradstyris New Member

    Hi maryjohn
    Java is not a fully object oriented. My Collage sir told me that it is not fully object oriented. Actually javascript is a script language which runs small part of Java code. And Java is not a language, it is a tool. If you want to conformation then you have to ask best Java programmer.
     
  6. alice789

    alice789 New Member

    Javascript is a common set of language instructions for your web browser, like a plug-in, that any website can use to manipulate the browser into performing actions.

    The benefit of this is that with one set of instructions, works across any browser in any operating system that supports Javascript.

    It's like gas for your car, doesn't matter the make or a model, still they all use the same type of gas. (mostly) that's Javascript.
     
  7. daviddakarai

    daviddakarai Member

    JavaScript is a scripting language designed primarily for adding interactivity to Web pages and creating Web applications.