Another great tag in ColdFusion 8 AKA Scorpio is the cfwindow tag. This tag create a popup window in the browser without creating a separate browser instance. While I thought this was a great Idea I wasn't quite sure where I would use this. Once I got to thinking I quickly realized that it would be much easier figuring out where I wouldn't use it. This tag is very useful in so many ways and I would like to point out my first idea. This is just a quick example with a little code. If we were going to create an actual tip of the day application we could go much more in depth.
Let us say for example that every time someone visits my blog I want to display a tip of the day to them. Even better you could read in some type of session variable for the users settings or place a cookie on their machine. The session variable would tell us if we should display the tip of the day or not. If so we simply build our new tip of the day window. First off this is another tag that can take attributes as a structure and this seems to be better code to me so I am sticking with it. Here were are just defining the basic properties of our new window. For more information about all of the windows attributes please see the cfml reference.
2 <cfset win.name = "totd">
3 <cfset win.title = "Tip Of The Day">
4 <cfset win.center = true>
5 <cfset win.closable = true>
6 <cfset win.draggable = true>
7 <cfset win.initShow = true>
8 <cfset win.modal = true>
9 <cfset win.width = 600>
10 <cfset win.height = 300>
11 <cfset win.resizable = true>
2 <cfif session.showTOTD>
3 <cfwindow attributeCollection="#win#">
4
5 <h4>Did You Know?</h4>
6 <p>Here are a couple tips when navigating around my website.</p>
7
8 <ul>
9 <li>You can use the search box to the right to search all archived articles</li>
10 <li>By clicking on a subject under archives by subject you can see a listing of all articles by subject</li>
11 <li>You can email me using danvega@gmail.com</li>
12 <li>I use gtalk so you can contact me there as well</li>
13 <li>Lebron James Is King James to you!</li>
14 </ul>
15 </cfwindow>
16 </cfif>
If you would like to check out the demo I built you can visit the link below. Here is the final code I used.
2
3<html>
4<head>
5 <title>CFWindow / Tip Of The Day</title>
6 <style>
7 body,li,p {
8 font-family:Arial,sans-serif;
9 font-size:12px;
10 }
11 </style>
12</head>
13
14<body>
15
16 <img src="images/website.jpg">
17
18 <!--- show tip of the day --->
19 <cfset session.showTOTD = true>
20 <!--- just in case we forgot to set it --->
21 <cfparam name="session.showTOTD" default="false"/>
22
23 <cfset win = structNew()>
24 <cfset win.name = "totd">
25 <cfset win.title = "Tip Of The Day">
26 <cfset win.center = true>
27 <cfset win.closable = true>
28 <cfset win.draggable = true>
29 <cfset win.initShow = true>
30 <cfset win.modal = true>
31 <cfset win.width = 600>
32 <cfset win.height = 300>
33 <cfset win.resizable = true>
34
35 <!--- session variable for tip of the day --->
36 <cfif session.showTOTD>
37 <cfwindow attributeCollection="#win#">
38
39 <h4>Did You Know?</h4>
40 <p>Here are a couple tips when navigating around my website.</p>
41
42 <ul>
43 <li>You can use the search box to the right to search all archived articles</li>
44 <li>By clicking on a subject under archives by subject you can see a listing of all articles by subject</li>
45 <li>You can email me using danvega@gmail.com</li>
46 <li>I use gtalk so you can contact me there as well</li>
47 <li>Lebron James Is King James to you!</li>
48 </ul>
49 </cfwindow>
50 </cfif>
51
52</body>
53</html>
http://h127408.cf8beta.com/ajax/tipoftheday.cfm

#1 by Andy Matthews on 6/1/07 - 10:36 PM
When viewing the demo in IE6, I get a tiny bit of vert scrolling, but about 3 inches of hor scrolling.
#2 by Rey Bango on 6/2/07 - 7:30 PM
#3 by Dom on 6/6/07 - 9:48 AM
#4 by Andy Matthews on 6/6/07 - 9:54 AM
#5 by Dan on 6/6/07 - 9:54 AM
In theory it should work. I am thinking you can use cfhttp to grab the content. So in your example you would click a button on your site that would open this window and based on some url variable we would grab the content via cfhttp right? If thats right Ill give it a quick test.
#6 by Dom on 6/6/07 - 10:06 AM
#7 by Adam on 7/18/07 - 7:32 PM
ColdFusion.Window.Location('windowname', 'newUrl');
would make my life a lot easier!
#8 by todd sharp on 7/18/07 - 9:19 PM
1. use binding within the source
Ex: source="myTemplate.cfm?foo={something}"
2. use ColdFusion.navigate('myTemplate.cfm', 'myWindow_body')
Each window gets two special variables created - windowName_title and windowName_body that you can use just like any standard div in JavaScript.
does that make sense?