
814
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
<html>
<head>
<script language="javascript">
//Boolean value tacking the window state.
var shown=true;
//Functions to display an alert box when
function onshow(name) {
alert("window shown = " + name);
}
function onhide(name) {
alert("window hidden = " + name);
}
//Initialize the window show/hide behavior.
function initWindow() {
ColdFusion.Window.onShow("testWindow", onshow);
ColdFusion.Window.onHide("testWindow", onhide);
}
//Show or hide the window, depending on its current state.
function toggleWindow() {
if (shown) {
ColdFusion.Window.hide("testWindow");
shown = false;
}
else {
ColdFusion.Window.show("testWindow");
shown = true;
}
}
</script>
</head>
<!-- The body tag onLoad event calls the window show/hide initializer function. -->
<body onLoad="initWindow()">
<cfwindow name="testWindow" initshow=true title="test window" closable=true> Window contents
</cfwindow>
<cfform>
<cfinput name="button" value="Toggle Window" onclick="javascript:toggleWindow()"
type="button"/>
</cfform>
</body>
</html>
Control container contents
ColdFusion provides a variety of ways to set and change container tag contents:
•
You can use bind expressions in the container tag source (or for
cfdiv
,
bind
) attribute. The container then
dynamically updates any time a bound control changes.
•
You can call the
ColdFuson.navigate
function to change the container body to be the contents returned by a
specified URL. This function lets you specify a callback handler to do additional processing after the new content
loads, and also lets you specify an error handler.