Miscellaneous
  Home arrow Miscellaneous arrow Introduction to Java Script
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Introduction to Java Script
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2004-02-08

    Table of Contents:
  • Introduction to Java Script
  • Variables
  • Prompts
  • If -Then Statements

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introduction to Java Script


    (Page 1 of 4 )

    Many times when you are building a web page you might need more than just PHP and HTML. Java Script can fill that gap. In this tutorial, John Johnston will get you started with Java Script.

    By : John Johnston

    Java Script, not the same thing as Java which is an entirely different language and used for very different reasons, is a web based scripting (programming ) language developed by Netscape and is used to add interactivity to web pages. While it can be simple to use, like all programming languages, JavaScript follows strict syntax rules that you cannot break. If you don’t follow the syntax, it will not work.

    How Does Java Script Work?

    Java Script works by telling your browser that (1) it is a language on your browser, and (2) what to do with the scripts that you write. This is of course, over simplified, but we are not developers of languages, nor senior programmers, so we aren’t going to concern ourselves with how this all works. What we will consider is how to make it work and which browsers will and won’t use Java Script.

    Does Java Script Work on all Browsers?

    Unfortunately, no. While most versions of Netscape and Internet Explorer will work ( from version 3 on for both ), some browsers simply don’t understand Java Script and as such, we are required to hide these scripts from those browsers so that people don’t hunt us down and complain. To make things even more complicated, not all browsers handle JavaScript in the same manner. While the end result is the same, how the browser does it may be entirely different, even in the same version of a browser! Scared? Don’t be. Java Script can be the simpelist and easiest way to handle all your web based programming needs.

    Now some of you might ask about those browsers that don’t handle JavaScript. In essence, these browsers would just spit out all the scripting you have done as text in your HTML page. This would confuse everyone. Luckily, HTML has a built in way to comment, or hide, these things. In this way, we can hide our Script from browsers that cannot read it, and still let the browsers that can use it! How? Take a look below.

    <html>
    <head>
    <title> Title of your page </title>
    <script language="JavaScript">
    <!-- hide this stuff from other browsers
    YOUR SCRIPT HERE
    // end the hiding comment -->
    </script>
    </head>

    You should notice several things right off the bat. First, we have to tell our browser that we are using Java Script. ( <script language="JavaScript">). While Java Script is the default scripting language for browsers, this might not always be the case, and it is a good idea to keep it in there. The next thing that you should notice is that we have hidden our script from the browsers that can’t handle it with ( <!-- something //-->). The third thing that you should notice is that this script is placed entirely within the head of the HTML document. Most of your scripting will happen here. While you can, and will, use JavaScript in the body of your document, all of the really important programming will occur in the head. Finally, you should notice that just like basic HTML, you must open and close your script tags.

    A Note on Programming

    Some of the most important things about programming are not necessarily its function, but rather it’s format. Just like writing a research paper, the greatest paper in the world will do you no good if other people can’t read and understand it. Programming is no different. Form and style do count. The single easiest way to make sure that people understand what you are doing and why is to comment out areas of your script. This acts as a simple way to note things in your script so that it is easy to understand for those who want to steal your scripts…or for scripts that you want to steal yourself! To comment out a section just follow the format below.

    /* this is
    a huge block
    of text that I've
    commented out */

    Anything placed between the /* blah blah blah */ will be ignored by both HTML and JavaScript. With that let’s start some scripting!

    More Miscellaneous Articles
    More By Codewalkers


       · thanks
       · Found some errors in the end:if(var_1 &lt; var_2) &amp;&amp; (var_1...
     

    MISCELLANEOUS ARTICLES

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway