We help IT Professionals succeed at work.

cfwindow to open vertically centered, even when scrolling

gdemaria
gdemaria asked
on
I have a long list of data in a table.   When clicking on a row, I use cfwindow to pop-up more information about the clicked item.

The problem is that when the user scrolls down the page, cfwindow pops open the window way up at the top of the page, out of view and the user doesn't know it has opened.  So I need the pop-up window to open (or reposition) to where the center of the screen vertically, even if the user has scrolled down the page.

It seems that cfwindow will open pretty well the first time, but will always re-open to that same location each time after the first one.   So I may have to move it after open.  

Thanks for any ideas!
Comment
Watch Question

Manager Technology
Commented:
Here is a little javaScript function I created to do what you want. There is a lot you can do with the underlying Ext object that Adobe used to create the cfwindow functionality. There are more examples in this article on my Blog:

http://www.coldfusionguy.com/ColdFusion/blog/index.cfm/2007/12/4/CF8-AJAX-Features-Enhancing-CFWindow-with-JavaScript
<script language="JavaScript">
centerWindow = function(windowName){
//Get window object
myWindow = ColdFusion.Window.getWindowObject(windowName);
 
//use the centerfunction to center the window.
myWindow.center();
 
}
</script>
 
 
<a href="javascript:ColdFusion.Window.show('mywindow');centerWindow('mywindow');">Click here for more info</a>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<a href="javascript:ColdFusion.Window.show('mywindow');centerWindow('mywindow');">Click here for more info</a>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<a href="javascript:ColdFusion.Window.show('mywindow');centerWindow('mywindow');">Click here for more info</a>
<cfwindow name="mywindow" initshow="false">
	<table width="100%"><tr><td align="center" valign="middle">Here is some more info. </td></tr></table>
</cfwindow>

Open in new window

CERTIFIED EXPERT

Author

Commented:
Fantastic!  Thanks very much
Just want to say thank you for the script.  I was running into this issue as well and this worked great!