logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g HTML Site

BellaOnline's HTML Editor

g

Javascript Basics

Guest Author - Elizabeth Connick

Javascript is a great way to add some interactivity to your website. With HTML alone your pages will be completely static, but if you throw in a few Javascript snippets you can have a site that will respond to your visitors' actions and a whole lot more.

One thing that tends to confuse web developers is that Javascript and Java sound a lot alike. Actually, they have nothing in common! Java is a programming language, while Javascript is strictly a scripting tool – it's not really complex enough to be considered its own language.

When you're ready to add some Javascript to your website, you have several options. First, you can write the code in its own page, and then call it in the webpage's header – this works much like adding a CSS page, except that you must also add a command somewhere within the webpage's body to activate the script. Second, you can write the script in the webpage's own header; again, you'll need to add some code to the page body to run the script. And third, you can write the code directly into the page body. This option is feasible for very short scripts only – otherwise you'll be cluttering up your HTML pretty badly!

Wherever you add your Javascript code, you'll need to tell the browser that what you are writing is to be interpreted as Javascript. You do this by placing the code between the following tags:

<script></script>

For full HTML compliance, it's best to add an attribute to the script tag so that your visitor's browsers know for certain it's Javascript and not some other script:

<script type="text/javascript"></script>

Finally, to be completely on the safe side it's wise to comment out everything between the script tags. That way if you have a visitor who happens to be running a prehistoric browser, they won't end up with a screen full of garbage. So your web page's Javascript will look something like this:

<script type="text/javascript">
<!--
Code goes here…
//-->
</script>

And speaking of comments, you can add comments to Javascript much as you can with HTML and CSS. In Javascript, comments are marked with // at the beginning of the line. That's why you'd include the two slashes before the end comment in the above example.
This site needs an editor - click to learn more!

Add Javascript+Basics to Twitter Add Javascript+Basics to Facebook Add Javascript+Basics to MySpace Add Javascript+Basics to Del.icio.us Digg Javascript+Basics Add Javascript+Basics to Yahoo My Web Add Javascript+Basics to Google Bookmarks Add Javascript+Basics to Stumbleupon Add Javascript+Basics to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the HTML Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Elizabeth Connick. All rights reserved.
This content was written by Elizabeth Connick. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
What's Coming in HTML 5

What is FTP?

HTML Fundamentals - Tables

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor