logotonero

"walks, history, London and more"
computing> snippets

Javascript Snippets

View source to extract the code. In each case, the required functions have been located immediately above the relevant text for easy copying. Once you have inserted the text in the new location, the functions can be cut and pasted in the head section of that document. Note that the code on this page conforms to XHTML 1 transitional.

currencon function always gives two decimal places:

Quantity: Price: Total value:

todate functioncalculates days ahead:
There are now days to the year 2030!

dateconv function takes a date and translates it into meaningful terms:

The current date is

tohex function converts decimals to hexadecimals:
a full colour converter and tester is located under tools

Decimal value up to 255: Hex value:

Mileage Converter. The converter below calculates to a large number of decimal places (1 kilometre = 0.621371192 miles) and then rounds the result to two decimal places. To use the round function the result is multiplied by 100, rounded and divided by 100
 
 
   
 
Here is a simpler instant calculator without rounding function:
  result in miles:

A javascript rollover
This script includes a preload function.

Image swap used extensively on this site, with the JavaScript wholly built into the HTML:

no more photos

Conditional text, in this case dependent on the existence of a top frame. This is to display links not valid in different situations:

A simple cookie
To create a cookie on your site, enter a value into the text box below and press Set cookie. Press Get cookie to retrieve it at any time up to 30 days. You can also read the cookie details in your cookie folder with notepad:

Enter value:

A javascript back button takes you back to where you came from return

Creating a selfcontained window

initiator of window 1   initiator of window 2

To visit other pages using a Remote selector - currently under development