/Main_Page

::You must have ninja focus to complete your mission::NinjaFocus::

Javascript Boilerplate

Views:


This is more or less the template I'll use to control javascript in any new web site. It depends on my Javascript Utility Class and usually gets dropped in to a new site along with my HTML Boilerplate and CSS Boilerplate.

/*****************************************************************
 * This is the file for your custom javascript for your web site *
 *****************************************************************/
 
/************************
 * Function Declarations
 */


/*
 * End Function Declarations
 ****************************/
/*******************
 * Global Variables
 */


/*
 * End Global Variables
 ***********************/
/***************************************************************************************
 * Initialisation Code - code in this area will run as soon as the document has loaded
 *
 * Place here the javascript code and function calls you would like to run when the page loads
 * Note: If you use sifr text you should put your sifr code at the very bottom of this file.
 */
DomLoaded.load(
    function() {
        // Place your initialisation code here (this is like body.onload)
        
            // Nice fonts for menus
            K.textToImage('primarymenu');
            // XHTML compatible target="_blank"
            K.externalLinks();
            
            // Validate forms before submission
            if (document.getElementById('main') && document.getElementById('main').getElementsByTagName('form'))
            {
                var forms = document.getElementById('main').getElementsByTagName('form');
                for (var i = 0; i < forms.length; ++i)
                {
                    forms.item(i).onsubmit = function () {
                        return K.formSubmissionCheck(this, 'Please fill in this box');
                    }
                }
            }
        
            // Call Google Analytics Last of all to prevent possible performance issues
            K.analytics();
            
        // --------------------------------------------------------------
    }
);
/*
 * End Initialisation Code
 **************************/
/*******************************
 * SWFObject - Degradable Flash 
 *
 * SWFObject can give users a friendly message to udpdate their version of 
 * flash or strip out flash content that is not supported. It does this in 
 * a graceful way with fall-back content. The user need not know.
 */
if (typeof swfobject != "undefined")
{
    // Your code for detecting flash versions should go here.
    
    
    // --------------------------------------------------------------
}
/*
 * End SWFObject Code
 *********************/
/************
 * Sifr Code
 */
if (typeof sIFR != "undefined")
{     
    // Your code for loading Sifr should go here (if applicable)
   
        
   // ----------------------------------------------------------
}
/*
 * End Sifr Code
 ****************/

Main Menu

Personal tools

Toolbox