©1999-2000. Comments or Questions about this page? Please e-mail the PCTechPH@yahoo.com . All Rights Reserved.
JavaScript Tutorial |
Last Revised: 01/10/2004 |
Quick Study |
Ok, let's get started with JavaScript. The tags used to begin and end a script are the <SCRIPT> and </SCRIPT> tags. The opening tag should appear like this: < SCRIPT language="JavaScript"> . The JavaScript code will follow this tag, and end with the < /SCRIPT> tag <SCRIPT language="JavaScript">.
What is JavaScript anyway? JavaScript, developed by Netscape Communications joined with Sun Microsystems. Java and JavaScript are two completely different programming language. You do not need to be a programmer to use JavaScript. JavaScript is a popular program that most Webmaster used to create their homepage because it is supported by both Microsoft and Netscape.
Lets proceed to the main topic of this tutorial. An example of Java Scripting:
The "Hello World" will display once you open/access the web site. The document.write("Hello,World") between the <SCRIPT> read by the browser and load into it. Another example is when you want to have the pop up when you enter the web page. Simply change the "document.write" to "alert" like "alert("Hello,World!"). You can also use the 'prompt" command in connection with the pops up. It will prompt you a window to enter a text or message. However using the PROMPT will need to use a variable like "var NAME=prompt("Enter your own message here","")". So once you access a web page it will ask for your name.
NOTE: Not all browsers are capable of reading JavaScript, since there are older browsers being used out there that are having a hard time or reading JavaScript. Older browser like, MSIE 3.0 and Netscacpe 3.0 they do not recognize the < SCRIPT> tag. To avoid this problem, you have to trick the browser into ignoring the text within the < SCRIPT> . This is done by using an HTML comment.
This is the SOURCE code:
Another example in using JavaScript is "onMouseOver". In creating page for a Web site, a roll over (some people call it a "mouse over") is a technique using JavaScript that lets you change a page element (usually a graphic image) when the user rolls the mouse over something on the page (like a line of text or a graphic image).
The term roll over recognizes that there is a little ball in your mouse that you roll on a surface. Some common uses of the roll over include:
Inviting user interaction by causing text elements in a menu to "pop up" or otherwise become lively as you roll the mouse over each line. This is done by creating a small graphic image for each text line and a second graphic image for each line that is substituted when a given text line is rolled over with a mouse. The effect invites users to click on one of the rolled over lines. Causing a previously invisible graphic image or other element to suddenly appear when the user rolls the mouse over a particular page element.Did you see the changes when you move your mouse to a LINK? That is the example of On Mouse Over. It will display the message on windows status bar below the window. One more example of this is to put graphic image for each line that is substituted when given text line is rolled over with a mouse. The effect is that the Text will change it to a graphics when you roll the mouse. One more thing if you want to change the color background of your webpage when you move your mouse to a certain link it will change its background color.
The On Mouse Over is another command for making your page more interesting. When you move your mouse to a certain word it will display a pop up message or a message in your Status Bar. On Mouse Over are very simple command but sometimes its tricky. JavaScript and OnMouse are likely the same, you can design your webpage like in a Flash Player and DHTML ( Dynamic Hyper-Text Markup Language ).
Another example of On Mouse Over effect :
Another OnMouse effect is the status bar, move you mouse over to the link and check the Status Bar. Pretty neat isn't, to see the code see below.
Also use this command if you want a flip image effect, there are two ways in doing this, one using the " on Mouse Over" and the second one is "function" command script. First, we have to use the "on Mouse Over" flip image, we will use the method "Hlpstep1.gif and Hlpstep2.gif" as our images for this tutorial.
The source code for this command as follow:
We have tackle onMouse Over Image flip, now let's proceed with the next Script using the "function" command.
An example of function Image onMouse Roll over using JAVA :
This is the SOURCE:
Another example using the JavaScript is where you can change colors of a certain background. You can click on the Example button below to check the background effect.
The SOURCE:
The Example Background effect using onMouse:
Javascript is the most commonly use when using Mouse Over, it will help you to customize the body of your webpage. You can use the JavaScript if you want to open a certain window that control the size and height in a separate window. Command that let the browser to read the script to Open Window. It will Open Window in a pop up form that you have specified on the Javascript command tag.
Here is an example about a pop up JavaScript:
To activate the JavaScript you have to include this command at the < Body > of your webpage.
To see the effect, click on this button
In our example, have you notice the < FORM > tag that we used? Yes, you can also use that command to be able to have an open window, very neat isn't?
Some webpage developer doesn't want their "Source Code" to be view by others using the right click function and the VIEW SOURCE. They use this command tag to prevent surfers from easily saving your webpage and viewing its source code.When you press the right mouse key, a pop up message that will tell you that "this function is disabled by the webmaster". You can change the Text message on the pop up window with your own style. I have just put mine as it show in your screen when you right click on it.
Some web pages have this Pop Up window where in you have to enter your Name or any information to be able to enter the web page. This command is another method we use to prompt you to enter your NAME. We use the VARIABLE command to call the method. Once you refresh the page you will see the pop up message on the web site. Try the script below:
This command Prompt read the variable in a method and display it as a prompt when you enter the page. The next command is more on checking on your Windows version, Internet Explorer or application you are using. I read this script on Dr Joe web sites and I just wanted to share it to you. You can visit his website that really help you with regard to JavaScript Command. His site has all the information you needed and to learned. Visit
Source Code for the above EXAMPLE:
That's all I can share about JavaScripts!
[ Table Tutorial ] [ Keyboard Shortcut ] [ Cascading Style Sheet ]
[ List Tutorial ]
[ DIV tag Tutorial ] [ Filter Effect ]