Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: JavaScript for Beginners  (Read 775 times)

0 Members and 1 Guest are viewing this topic.
JavaScript for Beginners
« on: April 30, 2007, 08:59:07 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1645
Here's an old tutorial of me about JavaScript...
If you can barely read the codes, Here is the original tutorial.

Quote
This is what you need before starting:
- Basic HTML knowledge
- Notepad or something else
- JS enabled web browser
 
What is JavaScript?
 
JavaScript is a web scripting language, That means that it is a script inside a web page. A web page is based on HTML and JavaScript is a kind of extension to it. The script is based on a real programing language named C. It's a simple version of it, Without using a compiler and other difficult things, Because it's already built in the page.
 
The History of JavaScript
 
JavaScript was created by Netscape and Sun. Netscape wanted to make a programming language that can do things like Java and useful for a site. The first name before JavaScript was named 'Mocha' and some years later it was named 'Live Script'. When Live Script was very popular and well-known, The Script is finally named 'JavaScript'. But remember, JavaScript is not Java. Java is a very detailed and difficult programming language for making powerful applications.
 
Writing in JavaScript
 
Are you ready? Okay! We will begin. If you don't know how to run a web script, Open Notepad using the start menu or using the start > run, and typing notepad. When you are done and want to test your script, Save the page as a .htm or .html file, And open it with your web browser. To make a Javascript working, You have to use a HTML tag to open it.
 
Code: [Select]
<script></script>
This is just the base of it, The script tag needs a attribute type on it. Add the type attribute and set the value to "text/javascript". That will let your page know that the script is wrote in JavaScript.
 
Code: [Select]
<script type="text/javascript"></script>
If you're done with the begin of it, You can start using JavaScript. The first code that I can teach you, Is how to write something on your page with JavaScript. It's very easy to using the write command.
 
Code: [Select]
document.write("hello world!")
Well, I said to use the write command. But why the document with a dot? Because the document tag means that your command is targeted to your document page, So actually it's the write() command + the document as your target. After declaring the target, It always need a "." dot.

So if you get it now, Your first JavaScript code will look like this.
 
Code: [Select]
<script type="text/javascript">

document.write("Hello World!");

</script>

The next important thing is to add a ";" after a command line, That will prevent you crossing the whole script and making bugs. The ";" thing will make a end line after your code.
 
Code: [Select]
document.write("Hello<br>"); document.write("World!");
Don't forget that the document.write will write something down in your page, like a paragraph. So HTML tags always works, But Watch out! Don't use a " double quote if you did the same on the attribute="value". The script will see the quote as a stop and will mess up your script.

So I suggest you to use a ' single quote. Like this attribute='value', And like this.
 
Code: [Select]
document.write("<div class='style'>Hello Styling!</div>")
If you didn't do that, And you just left the quotes of the HTML as a double quote, It will look like this.
 
Code: [Select]
document.write("<div class="style">THIS IS WRONG</div>")
The document.write("") command have got "" quotes means things that are in the quotes is Text. If you don't have that, The page will see it as a variable or string. So it wouldn't write something.
 
Code: [Select]
document.write(THIS IS WRONG);
Well done dude! If you followed the steps in a right way. You should understand how the basic of JavaScript works

Sorry for the grammar errors, English is my 4th language.
« Last Edit: April 30, 2007, 09:02:31 am by TheRealDragonboy »
Logged
  • Virtual Security
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.264 seconds with 39 queries.

anything