Thursday, December 2, 2010

How to Make A Website With Javascript ?

Put a JavaScript into an HTML page

The example below shows how to use JavaScript to write text on a web page:

Example

<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>

Example Explained

To insert a JavaScript into an HTML page, we use the <script> tag. Inside the <script> tag we use the type attribute to define the scripting language.
So, the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends:

<html>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>
   

The document.write command is a standard JavaScript command for writing output to a page.
By entering the document.write command between the <script> and </script> tags, the browser will recognize it as a JavaScript command and execute the code line. In this case the browser will write Hello World! to the page:

  <html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>
        

Note: If we had not entered the <script> tag, the browser would have treated the document.write("Hello World!") command as pure text, and just write the entire line on the page. Try it yourself

How to Handle Simple Browsers

Browsers that do not support JavaScript, will display JavaScript as page content.
To prevent them from doing this, and as a part of the JavaScript standard, the HTML comment tag should be used to "hide" the JavaScript.
Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of comment) after the last JavaScript statement, like this:

<html>
<body>
<script type="text/javascript">
<!--
document.write("Hello World!");
//-->
</script>
</body>
</html>
 

The two forward slashes at the end of comment line (//) is the JavaScript comment symbol. This prevents JavaScript from executing the --> tag.

Wednesday, October 20, 2010

About JavaScript

JavaScript was first introduced by Netscape in 1995. At first the language is called "LiveScript" that serves as a simple language for the browser Netscape Navigator 2. At that time Javascript had received much criticism because of the lack of security, development that seemed to rush and no error message is displayed each time we make a mistake when preparing a program.
In line with the jealous co-operation between Netscape and Sun (the developer programming language "Java") at the time, then Netscape gave the name "JavaScript" to the language on 4 December 1995. At the same time, Microsoft's own attempt to adapt this technology, which they called "JScript" in your Internet Explorer 3.
Javascript is a language that shaped a collection of scripts on the function running on an HTML document. Throughout the history of the Internet language is the first scripting language for the Web. This language is a programming language to provide additional capability to the HTML language to allow the execution of the commands on the user side, which means in the browser rather than on the side of the web server.


JavaScript is a programming language that was designed for the web. Many people don't understand that JavaScript is not the same as Java, the programming language. In fact, Java and JavaScript couldn't be more different. Java is very complicated, JavaScript is not. Regardless of popular belief, JavaScript is not a condensed version of Java in any way. One has nothing to do with the other.

JavaScript can be used to manipulate your webpages to perform a variety of functions. Some of the applications are purely functional, while others are just fun. In fact, you don't have to know any JavaScript at all, because there are numerous scripts out there that you can simply grab and paste into your HTML code.

But at the same time, if you want the JavaScript to be effective, and to do what you want it to do, you do need to at least have a basic understanding of JavaScript, how it is written, and how it works. This tutorial will provide that information for you, starting with the very basics, and then working into a few advanced topics. A working knowledge of the basics is necessary.

You do not, however, need to know HTML to learn JavaScript. It does help, but it isn't necessary since JavaScript doesn't use HTML, even though it is used with HTML. You do need to know how to work with your HTML documents, however, because you will be pasting your scripts into the HTML code, and you will need to know where to place the JavaScript. You do not need to know any programming language to learn JavaScript. The entire concept and writing of JavaScript is really quite simple.


What Can A JavaScript do ?

  • JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
  • JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page
  • JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
  • JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
  • JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
  • JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser
  • JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer
As stated earlier, you can use JavaScript to perform a variety of functions on your website. Some of the functions are just functional, while the others are more fun in nature, providing interactivity for your website visitors.

Face it. Nobody likes stale webpages that just sit there. They want to interact with them dynamically. JavaScript allows this to happen. JavaScript reacts to users actions in most cases. For instance, if the user moves their mouse over some text or a graphic, JavaScript can perform a rollover and make that graphic or text change to something else.

JavaScript can provide functionality, such as password protection, browser detection, or display information, such as the correct time and date on a webpage. JavaScript can be used to give the website designer more control over a user's browser, and how that browser sees the webpages. There are literally millions of things one can do with JavaScript.

JavaScript How To

Put a JavaScript into an HTML page

The example below shows how to use JavaScript to write text on a web page:

Example

<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>

    A little added income?

    readbud - get paid to read and rate articles