Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> The Basics Of Javascript, Basic.
DanWilliamson
post May 30 2006, 06:41 AM
Post #1


Regular Dot
Group Icon
Group: *Premier*
Posts: 56
Joined: 20-March 06
From: Manchester UK
Member No.: 10,400





Hey,

This is a basic tutorial that I have written about javascript.

What is javascript

javascript is a client-side scripting languages which is mainly used to make webpage better. It is probably the most popular scripting language, which is thought of as a lower programming language.

The basics & laying out javascript

If you know CSS you will find this bit very easy as it is basically the same but with different syntax, you need to open your javascript tag.

CODE
<script type="text/javascript">
<!--

javascript Code Here

//-->
</script>



This doesn't exactly do much but it has opened your javascript tag and closed it; also you can link to an external javascript file just like in CSS.

CODE
<script type="text/javascript" src="javascript.js">


This will link to the directory that you are on and pull the 'javascript.js file and use it, just like the external CSS file. We will start with the most common javascript basics which are document write and alert.

CODE
<script type="text/javascript">
<!--
    document.write("13Dots - javascript Tutorial");
//-->
</script>


This will execute the '13Dots - javascript Tutorial' onto your webpage with the default styling and really won't do anything, but you can play around with it for example.

CODE
<script type="text/javascript">
<!--
    document.write("<b>13Dots</b> - javascript Tutorial");
//-->
</script>


You can guess what this does as it uses the basic HTML tag for bold, you can use things like H1 but not like you actually use this tag too much so we will move on.

alerts are one of the most common yet most annoying scripts you will ever see. It simply opens a horrible pop-up on your web browser.

CODE
<script type="text/javascript">
<!--
    alert("13Dots - javascript Tutorial");
//-->
</script>


Now this will output in a pop-up box '13Dots - javascript Tutorial' and will just annoy the hell out of users so I recommend that you stay away from it when not needed.

Variables

Variables are in javascript as it is basically a programming language, you may have seen them in PHP or Visual Basic etc but they are also in javascript and here is how you define them and use them in your webpage.

CODE
<script type="text/javascript">
<!--
    var name = "Dan Williamson"
    document.write(name);
//-->
</script>


This will define the variable 'name' to hold 'Dan Williamson' and then excecute it onto the webpage using document write. You can also do maths with it etc but I won't show you how to do that in this tutorial as I won't go too in-depth, this is just the major basics of javascript, I will be writing another one tomorrow with will feature:
  • Functions
  • Operators
  • Conditions
  • If/Else
Hope you liked this.


IPB
 
+Quote Post  Go to the top of the page
*D*
post May 30 2006, 04:10 PM
Post #2


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,988
Joined: 18-May 04
From: North Pole
Member No.: 2





thumbsup.gif Nice and simple, thanks for adding Dan.
 
+Quote Post  Go to the top of the page
RedDragon
post May 30 2006, 10:28 PM
Post #3


insert coin
Group Icon
Group: Main Team
Posts: 5,344
Joined: 24-May 04
From: Maastricht
Member No.: 35





Thanks Dan! victory.gif


IPB
 
+Quote Post  Go to the top of the page

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 20th November 2008 - 08:53 AM
Buy PSP | Free Myspace Layouts | 0 Credit Cards | Credit Counseling | Loans