Tonylondon

design > tools > 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 inserted in the new location, the functions can be cut and pasted in the head section. 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 2010!

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:

A javascript rollover
This script includes a preload function.

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

This javascript initiates a window and fills it with text from within its own file.

initiator of window 1   initiator of window 2

To visit the pages use the Remote selector

Next page

home   • serviceslocal infodesign infomy Londonback to tophelp