Jump to content

JavaScript/Basics

From IdeaWazaWiki
Revision as of 13:39, 17 May 2007 by wikademia>Hampshire2004 (Reworked grammar, added note on tags)

Basic JavaScript is a course under the topic of JavaScript.

What you should know - HTML/XHTML

Basics -

  • JavaScript is the most popular web page scripting language and is suppported by almost every browser.
  • It adds interactivity to your web pages.
  • You can use only the tools all ready on your computer with out the need to download any software.
  • It is easy and fun

First Lesson

Open up your text editor of choice and create a basic page. Now I am going to teach you how to write on your webpage using JavaScript.

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

As you can see, JavaScript is added directly into your HTML by adding the <script> tag. You don't have to understand exactly how that worked, I'm about to explain.

To start off with, the <script type"text/javascript"> tag tells the browser that whatever comes between that tag and the coming </script> tag is JavaScript. Similarly, to use VBScript, you might add a <script type="text/vbscript"> tag. For the purposes of this course, though, you should only ever need to use the JavaScript tag.

It is also important to note that JavaScript is case sensitive. What this means is what ever you type must be in capitalized the way it should be. For example, if you wrote

<ScRiPt TyPe="TeXt/JaVaScRiPt">

not only would you waste a lot of time typing, but you would also confuse your browser.
You are probably wondering when I'm going to explain the rest of what you did. Well, document.write is the JavaScript standard for writing text to the browser window. The 'document' clause refers to the HTML webpage (termed a document) as a whole; what follows ('.write') is a command for the document object to carry out. In this case, you told the page to write the classic "Hello World" to the screen.
These are the absolute essentials to understand for starting JavaScript.
--Xora K Joken 19:18, 3 April 2007 (UTC)