Basic Javascript

Brief overview of javascript and some of the common scripts

By: Craig
What is JavaScript?



JavaScript is a script language - a system of programming codes, created by Netscape, that can be embedded into the HTML of a web page to add functionality. JavaScript should not be confused with the Java programming language. In general, script languages such as JavaScript are easier and faster to code than more structured languages such as Java and C++.

JavaScript is client-based, which means it does not have to make any server requests to run. This makes it ideal for fast response and initial validation of form input.

When combined with CSS, JavaScript can create dynamic effects using Dynamic HTML.

JavaScript is event driven, meaning it acts on events that happen on the screen such as clicking a button.

JavaScript is normally inserted into the HEAD section of the web page surrounded by a <SCRIPT> tag. It is generally called from the HTML in the web page BODY in response to an event, such as a mouse click. JavaScript can also be inserted directly into the BODY section of the web page.

Here are some basic scripts that may come in useful. Modify and experiment with them

A pop up window



<HTML>

<HEAD>

<TITLE>Opening a pop-up window</TITLE>

<SCRIPT LANGUAGE="JavaScript">

function popupwin(){

winpopup=window.open("","popup","height=300,width=400");

winpopup.[removed]('<HTML>\n<HEAD>\n');

winpopup.[removed]('<TITLE>This is a popup window</TITLE>');

winpopup.[removed]('</HEAD\n<BODY>\n');

winpopup.[removed]('<FORM NAME="otherform">\n');

winpopup.[removed]('<INPUT VALUE="Close Window">\n');

winpopup.[removed]('</FORM>\n</BODY>\n</HTML>');

winpopup.document.bgColor="blue";

return;

}

</SCRIPT>

</HEAD>

<BODY>

<H1>JavaScript Pop-up Window</H1>

<P>

<FORM NAME="form">

Please CLICK here to open a popup:

<INPUT VALUE="Open a Pop-up window">

</FORM>

<BODY>

</HTML>

Drop down menu link



<HTML>

<HEAD>

<TITLE>Opening a pop-up window</TITLE>

</HEAD>

<BODY>

<H1>Drop Down Menu Link</H1>

<FORM>

<SELECT NAME="menu">

<OPTION VALUE="http://google.com">Google</OPTION>

<OPTION VALUE="http://yahoo.com">Yahoo</OPTION>

<OPTION VALUE="http://ca-development.co.uk ">CA-Development</OPTION>

</SELECT>

<input type="button" value="Take me there">

</FORM>

<BODY>

</HTML>

Alert box



<HTML>

<HEAD>

<TITLE>Alert Box</TITLE>

</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">

alert("Welcome make yourself at home");

</SCRIPT>

</BODY>

</HTML>

I offer bespoke web design and web application development, aswell as custom software solutions for small business.

Visit me at CA-Development









Related Articles

ColdFusionThe list of officially supported languages is constantly changing. The following list is correct : * ActionScript * Ada * AppleScript * ASP * Assembly...
Dreamweaver allows users to preview websites in locally installed web browsers. It provides transfer and synchronization features, the ability to find...
JavascriptMany websites use JavaScript to add functionality to their website. Before you decide to add JavaScript to your site - or before you allow your web de...
JavascriptIt takes a lot of time to fully understand how JavaScript works and how to make a website function properly. It requires a lot of encoding and scripti...
WordPressIf you were to develop a site seven or eight years ago, you would likely need at least a basic understanding of programming codes like HTML or Javascr...