11.14.07
Posted in JavaScript at 2:04 am by admin
JavaScript is a very interesting programming language to use simply because it is a language that is so easy to use in conjunction with HTML and other web languages. JavaScript was initially designed for the web and is made even better for the web whenever it is updated, so it is quite easy to see why people are impressed with the JavaScript language. There are a number of things that you can do in order to make your website better with the JavaScript functions and therefore it is important for people to realize exactly what those functions happen to be.
For starters, one of those functions is known as the onload function. This is one of the earliest taught functions for JavaScript because of not only the ease of learning that it brings to the table, but also because it is one of the more basic functions around. Onloads will be big parts of larger chunks of JavaScript code and this is why it is important that people learn about them early on within their JavaScript training.
Now, like most pieces of code in JavaScript, it serves no purpose to verbally explain what the onload function does without using an example in order to help that illustration along. To that end, take a look at the following piece of code:
<html>
<head>
<script type=”text/javascript”>
Function message()
{
Alert(“Hello World”)
}
</script>
</head>
<body onload=”message()”>
</body>
</html>
Have you ever seen a prompt window pop up when you get to a website with a message for you to read and then at least one option button (i.e. the okay button, although sometimes there is more than one option depending on what the message says) for you to click? Well, if you stuck this little bit of code into your website, anyone that visited it would have a pop-up message that said “Hello World.”
This is done through the use of the message() function, but that is not the part of the code we are predominantly interested in. We are interested in the onload attribute of the body tag, which happens to execute the function that was defined within the head part of the HTML code. Attaching the onload attribute to the body tag ensures that the message() function is executed as soon as the site is displayed. Message() is not the only function that can be onloaded and therefore you can see easily now why the onload attribute is an important one to learn.
Scriptycan is a great software repository featuring both free and commercial JavaScript scripts and applications for developers and programmers.
Permalink
11.06.07
Posted in JavaScript at 12:30 pm by admin
In order to truly understand JavaScript you need to understand JavaScript variables. A variable is a word or a string that is responsible for containing information that you want to store in the JavaScript code. While the value of a variable can change during the script, you can also refer to the variable by the exact same name throughout the script once it has been initially defined. There are only two rules for defining variables.
The first rule is that variable names are case sensitive. This means that if you capitalise any letters in the variable name, it also means that you need to capitalise those letters elsewhere in the code for the computer to understand what you are talking about.
The second rule is that a variable defined in JavaScript must begin with the letter or the underscore character. If you do not define your variables with either a letter or the underscore character at the start of the variable than the browser will not be able to recognize it as a variable. As long as you stick to these two simple yet extremely important rules, you should have no problem defining various variables within your JavaScript code.
In order to illustrate these examples more clearly, let us take a look at a few simple variables as defined within the JavaScript code.
var strname = some value
This is an example of a variable that has been created through the use of the var statement. While this is certainly a correct example of a way to create a variable in JavaScript, at the same time you will find that usually the var statement is not necessary. In the above example, the same thing can be accomplished with the below piece of code.
Strname = some value
This might seem like splitting hairs to you, but when you are confronted with a complicated set of JavaScript code, you are going to be thankful if the person that programmed the code understood the concept of reducing redundancies in their variable statements.
Depending on where you declare your variables, they are either going to be local variables or global variables. Local variables are defined within a specific JavaScript function and therefore when that function is over, the variables no longer apply. Global variables, on the other hand, are defined outside of a function, meaning that all of the JavaScript functions on a single page can use them. There is currently no easy method to define variables beyond a single page of functions, which is why Global variables are given that name.
Scriptycan is a great software repository featuring both free and commercial JavaScript scripts and applications for developers and programmers.
Permalink
11.03.07
Posted in JavaScript at 5:34 am by admin
JavaScript is the premier scripting language on the Internet. It is the easiest way for programmers to do browser scripting. In order to be any kind of good Webmaster, you need to know how to use JavaScript. This oracle will introduce you to the most basic JavaScript imaginable.
Before we can start explaining how JavaScript works, you should see an example of JavaScript in work. The example below is the most basic JavaScript imaginable.
<Script type =”text/javascript”>
document.write(“Hello World!”)
</script>
Because of the words Hello World located with in the middle of the script, you have probably already guessed what this JavaScript is intended to do. Just in case you have not, this particular piece of JavaScript is intended to say the words Hello World on screen. In order to understand exactly how this piece of script works, it is important first to understand what each individual element of it does. In order to explain the, let us examine each individual line of code separately.
<script type=”text/javascript”>
This first line of script is not actually a JavaScript piece of code. It is a piece of HTML code. The main code being used here is the script code. The script code is responsible for letting the computer know that the upcoming lines of code are going to be JavaScript code.
document.write(“Hello World!”)
The second line of script is the actual JavaScript in this code. It is the line that is responsible for letting the browser know that the words Hello World need to be displayed in the browser, with the exclamation mark at the end. Ultimately, it is this line that represents what is actually happening in the actual coding world.
</script>
The final line closes the JavaScript at the end, letting the browser know that the JavaScript code is done for the moment. In other words, the <script> and </script> tags delineate a specific area within which JavaScript code is used. This code is used in order to let the document.write command be recognized as JavaScript, rather than be recognized as something else. If the <script> and </script> tags were not there, then the most likely resolution would have been that the words “document.write(“Hello World!”)” would actually have appeared in the browser, since it had no way of recognizing them as JavaScript rather than as text to be displayed. In the future, all JavaScript that you choose to include will need to be delineated with <script> and </script> tags.
Scriptycan is a great software repository featuring both free and commercial Java script scripts and applications for developers and programmers.
Permalink