Common Uses of JavaScript on Your Website

 JavaScript If you are building your own site from the bottom up, we recommend that you always keep potential JavaScript use in mind for particular features.  Building a website correctly relies often on how well all aspects of the site were built around each other from the start; everything should be relatively seamless and structural changes should not be necessary after it is officially deployed.  With that being said, JavaScript has some common functions in the world of web pages and the following functions are to be considered when implementing elements into your new web design.

Focus OnLoad Function

In instances where you would like to have the cursor automatically appear, making the selected text box immediately available for typing or input, you can use the Focus OnLoad function.  Besides making it far less likely that a visitor, customer or survey taker will miss or not notice the selected text box/question/option, it also makes information input much faster when combined with the ‘Tab’ key.  The Focus OnLoad function is a very small piece of code and takes up just one line of space.  Simply add the function to your body and make sure the form corresponds to the function and you’re all set.

IP Address Function

Another common JavaScript function is the display of a visitor’s IP address back to them, letting them know that you are cognizant of their presence and particular IP address.  This is used often on discussion boards and other websites where financial data or transactions occur.  Despite the presence of the code, there is no actual recording of the visitor’s IP by this script.  The IP address function can be modified to store the information to a database on your server, but the particular function covered here does not do that by default.  Perhaps we’ll cover that in a later topic.

Specified Referral Function

Ideal for websites with payment gateways and redirects, the specified referral function allows you to isolate individual web pages and specify particular gateways for access to these pages.  If you want a certain web page to be accessible only through one specific referral, you can use this function to make that so.  Common uses include pages confirming orders and secured log-ins with redirects.  The specified referral function is inserted before the ending head tag on the page in question.  If someone tries to access this page directly or through an invalid method, a message will be displayed informing them that they cannot access this page.

Date, Time and Calendar

Perhaps the most common JavaScript snippets are those that let you display the date and also a calendar on any given web page.  The calendar is a basic monthly calendar and can be altered using style sheets.  The data can also be displayed and can be altered to how the formatting of the date is displayed.  You can choose to show the year, the month (numerical or written-out), the date and the day of the week.  If you want to add the time to your site using JavaScript, check out Pingler’s JavaScript Clock tool for an easy way to show the time on your site, either in 24 hour format or in AM/PM.


  1. April 6th, 2012 4:43

    thx for sharing.. it is important for me..


  2. April 18th, 2012 6:43

    nice articles! thanks for your posting


Leave a reply translated

Your email address will not be published. Required fields are marked *

18 − 7 =