Causes the specified JavaScript function to run when the page loads.


This function does not return a value.


Function syntax


See also

cfdivcflayoutareacfpodcfwindowUsing Ajax User Interface Components and Features in the Developing ColdFusion Applications


ColdFusion 8: Added this function.





The name of the function to run when the page loads. The specified function does not take a parameter.


This function causes a JavaScript function to run when a page loads in the browser. The JavaScript function can perform any initialization actions that are required for the page to function properly. For example, a login window might open on a page if the user is not already logged in. You can use the AjaxOnLoad function to specify a JavaScript function that determines the login status and opens the window only if needed.You can use this function on top-level pages, or on pages that you dynamically include in your application by using the source attribute of the cfpod and cfwindow tags.


The following example uses the AjaxOnLoad function to call an init function each time the page loads. The init function displays a login window.

<title>Enter Mail Login Details</title> 

init = function() {'loginwindow'); 

<cfwindow name="loginwindow" title="Enter Login Details" 
draggable="false" closable="false" resizable="false" 
width="450" height="200"> 
<form action="#cgi.script_name#" method="post" name="loginform"> 
<table width="400" class="loginTable" cellpadding="5"> 
<td style="text-align: right">mail server:</td> 
<td><input type="text" name="server"></td> 
<td style="text-align: right">username:</td> 
<td><input type="text" name="username"></td> 
<td style="text-align: right">password:</td> 
<td><input type="password" name="password"></td> 
<td><input type="submit" name="login" value="Login"></td> 

<cfset AjaxOnLoad("init")> 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy