That's the problem with eternity; there's no telling when it will end.” Tom Stoppard
A resource for web developers a code snippet library with step by step tutorials.

a niche content web resource for geeks

       

Search Amazon

JavaScript: Extras - a bit more JavaScript

 

This page may add some extra abilities to your JavaScript knowledge base.


JavaScript code library snippets listed by subject.


Closing a window and navigating the window history.

1.

Calling a function from a hyperlink to close a window using JavaScript pseudo-protocol 'javascript:'.

2.

Calling a function from a hyperlink to go back in window history using JavaScript pseudo-protocol 'javascript:'.

Protecting your email address.

3.

Help prevent email trawlers picking up your email address from your website.

Place your email address in a JavaScript function.

Validating user input into a form using regular expressions.

4.

Regular expression for email address format.

Example of use in form validation.

Use of 'focus()' with the <body> 'onload' attribute and 'select()' to help user with form completion.

5.

Regular expression for UK postcode address format.

Example of use in form validation.

Use of 'focus()' with the <body> 'onload' attribute and 'select()' to help user with form completion.

Reading browser, navigation and web page properties.

6.

Browser version detection with the 'navigator' object.

7.

Referrer detection: detecting the previous page with 'document.referrer'.

8.

Detecting the location of the current page with 'document.location.href'.

9.

Capturing the 'get' method attribute query string with 'location.search'.

The 'get' query string is the value or the name and value pair(s) after the question mark (?) in a URI. Also known as the get parameters.

Example: http://www.justfigures.co.uk/snippet.php?query_string

or: http://www.justfigures.co.uk/snippet.php?value=query_string

 

Unescaping the query string and removing the name '?value=' to leave the parameter value only.

10.

Finding the date that the web page was last modified using 'document.lastModified'.

Further page manipulation.

11.

Refresh the page from a text hyperlink (anchor).

Using JavaScript pseudo-protocol 'javascript:' with 'document.location.reload()' and window.status='Refresh'.

12.

Using the 'window.onload' global event handler instead of the <body> 'onload' attribute.

Some web editing systems restrict access to the <body> tag for adding the 'onload' event handler. If this is the case use the global event handler 'window.onload' instead.

Suggest a code snippet to add to this page.

Rate this page:








Back to top.

 

Bookmark and Share

 

Copyright © 2006-2010 justfigures.co.uk