Broken (cf)windows?

This post is more than 2 years old.

A reader wrote in to say that this code, which worked fine in ColdFusion 8, now refuses to center in ColdFusion 9:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

<cfajaximport tags="cfwindow,cfform" />

<html xmlns="" xml:lang="en" lang="en"> <head> <title>My Test Window</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" />

<script language="JavaScript">

loginwin = function(){

  ColdFusion.Window.create('login', 'Account Login', 'login.cfm', {
        modal: true,
        closable: true,
        draggable: true,
        resizable: true,
        center: true,
        initshow: true,
        width: 300,
        height: 150


</script> </head>


<a onclick="loginwin();">Open the window</a>

</body> </html>

I thought perhaps it was the fancy DOCTYPE but removing that didn't help. The most I could guess at was some bug in the code used by the ColdFusion implementation. On a whim, I took a look at the Window object natively:

ob = ColdFusion.Window.getWindowObject('login') console.dir(ob)

Lo and behold, there was a center function. So to correct this issue, you can just do:

ob = ColdFusion.Window.getWindowObject('login')
Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA