Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

HelloWorld

249 views

Published on

Classic HelloWorld! tutorial

  • Be the first to comment

  • Be the first to like this

HelloWorld

  1. 1. Hello World!Traditional programming tutorial
  2. 2. Copy the following code and save it in a text editor as hello.html<html> You can use any text editor of<head> <title></title> your choice. I prefer notepad ++</head> http://notepad-plus- plus.org/download/v6.2.html<body></body></html>
  3. 3. Add script tags within head section The scripts tags tell the <html> <head> browser that there is <title></title> scripting contained <script between (in this case type="text/javascript"> “javaScript”). </script> </head> <body> </body> </html>
  4. 4. RememberScript tags are within the head section, not the body section.
  5. 5. Let’s make a function <html> <head>• A function executes a series <title></title> of instructions. <script type="text/javascript">• We will start with an empty shell function () { } </script> </head> <body> </body> </html>
  6. 6. Function name <html> <head>We will name our <title></title> <script type="text/javascript">function HelloWorld. function HelloWorld() {We will add an alert box alert ("Hello World!");that say’s “Hello }World!” </script> </head> <body> </body> </html>
  7. 7. Function Structure• The word function declares that there is a function.• The function name is HelloWorld.• Parentheses () (has use we will get to later in the course)• {} curly brackets contain the set of instructions
  8. 8. Execute Function <html> <head>Now that we have <title></title>covered the function <script type="text/javascript">head tags, let’s make itexecute when we click function HelloWorld() {on a link. alert ("Hello World!"); } </script> Here is a generic linkthat point nowhere: </head> <body> <a href="">Hello</a> </body> </html>
  9. 9. Execute Function <html> <head> <title></title>This will make it pointto our function <script type="text/javascript"> function HelloWorld() { alert ("Hello World!"); } </script> </head> <body> <a href=" javascript:HelloWorld()"> Hello</a> </body> </html>
  10. 10. Your turnAfter saving yourwork, try openingyourHelloWorld.htmlfile in your webbrowser.It should look likethis
  11. 11. Your first JavaScriptCongratulations, you just made your firstJavaScript!There are two things I would like you toremember:1. JavaScript and Java are not the same thing.2. JavaScript is case-sensitive!

×