Globale linker
Book 1
- Chapter 1
- Chapter 2
- Chapter 3
- Chapter 4
- Chapter 5
- Chapter 6
- Chapter 7
- Chapter 8
- Chapter 9
- Chapter 10
- Chapter 11
- Chapter 12
- Chapter 13
- Chapter 14
- Chapter 15
- Chapter 16/17
- Chapter 18/19
- Chapter 20
- Chapter 21
- Chapter 22/23
Book 2
Book 2 Ch. 2 JavaScript Fundamentals
JavaScript is a client-side scripting language that was developed by Netscape as an extension to HTML to allow designers manipulate Web page elements simply and easily. JavaScript will run in both Netscape and Microsoft browsers.
JavaScript provides several benefits to the web programmer, including short development cycle, a mild learning curve and platform independence.
JavaScript allows you to create web pages that interact with your users, based on their keyboard and mouse inputs. JavaScript functionality includes:
- Validating forms
- Rollovers
- Plug-in detection
- Browser detection
- Browser redirection
- Calculation
In JavaScript attributes and behaviors are called properties and methods. Properties represent various attributes of the object, such as height, color, size... and methods are the actions an object can be made to perform, such as calculation, onscreen movement or the writing of text.
- JavaScript is a scripting language
- JavaScript is object-based, not object-oriented (as Java is)
- JavaScript is event-driven (based upon user actions)
- JavaScript can reside on the server with the help of LiveWire
VBScript is a scripting language developed by Microsoft, and is a subset of Visual basic programming language. Will not run in Netscape browsers.
JScript is Microsoft's implementation of JavaScript. Several minor differences exist between the two, that results in that it will probably not run in Netscape browsers.
ECMA Script is a standardized scripting language.
JavaScripts are embedded into the HTML code with the HTML tag <script>.
<html>
<head>
<title>Page title</title>
<script language="JavaScript">
<!--
JavaScript code goes here
//-->
</script>
</head>
<body>
Page content
<script language="JavaScript">
<!--
JavaScript code goes here
//-->
</script>
</body>
</html>
The language attribute of the <script> tag tells the browser which type of script it is about to read. If you do not add the language attribute, the default scripting language in both NN and IE is JavaScript.
Notice that the comment tag <!-- is used to «comment out» or hide text in the script. You can add this in case a user browsing your pages has an old browser that is incapable of interpreting JavaScript.
Dot notation is used to associate an object's name with its properties or methods.
objectName.objectProperty
objectName.objectProperty = value
document.bgcolor = "#FFFFFF"
Communicating with the user is done with the following methods:
- alert()
Pops up an alert box conveying a message - prompt()
Pops up an alert box conveying a message and requesting input - confirm()
Pops up an alert box conveying a message giving the user two choices
Concatenation is used in JavaScript to combine text strings by adding them together with the + sign.
alert('Hello ' + prompt('What is your name',''));
New windows are opened with the open() method.
open("URL","windowname","featurelist")
open("http://www.donald.no","donald", "width=600,height=400,scrollbars=1")
The feature list contains a series of attributes that you specify as either displayed or not. The accepted values for these are 1 (or yes) and 0 (or no).
- toolbar
- location
- directories
- status
- menubar
- scrollbars
- resizable
- width in pixels
- height in pixels
- top in pixels
- left in pixels
A function is a set of JavaScript statements, that performs a specific task. The function can be called upon by user actions or in other functions.
See the JavaScript tutorial for further information.
