: DinkostaOnline - Scripts 2 :
 You are here : Web design > JavaScript > Miscellaneous scripts > Part twoDinkostaOnline 
Top links

HTML intro

CSS intro

Batch files

Introduction to JavaScript

Webmasterstuff

Speed-up&search the Internet

The Registry

Security on the Internet

About Pirot
Miscellanous scripts - Part 2
 In the second part of the miscellaneous scripts we'll start with an calculator. Below you can see an example of a simple calculator, made mostly with HTML and just a few lines of JavaScript ( here you can see the same calculator made with DHTML ).

  
 
 Put the following code into the <body> section of your document, where you want the calculator to appear:


Hotkeys (Internet Explorer only): You can make it possible to your Web Site visitors to use the keyboard to perform some actions or prohibit the use of some keyboard keys. Here is a short script that illustrates the use of hotkeys (put it in the <head> section):
To see how the script works, press Ctrl + q (an Alert - box pops up). In the event.keyCode = = part of the script you define which keyboard key has to be pressed in order to perform an action (17 is the keyCode for "Ctrl + q"). You can see a part of the keyCodes here (if you need the complete keyCode - table, order it by email). What should happen after the user hits the key is defined in the next line of code. If you put here, for instance, window.location="http://www.yahoo.geocities.com" instead of alert ('Example'), the visitor will be taken to the Geocities Homepage.
The ASCII key codes can be used with forms to determine what signs will be accepted in a certain field. The next script determines to accept only numbers into a field and no other signs:

Test the above script here:

1
Hosted by www.Geocities.ws