Broken (cf)windows?

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<cfajaximport tags=”cfwindow,cfform” />

<html xmlns=”http://www.w3.org/1999/xhtml” 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>

<body>

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

</body> </html> </code>

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') ob.center()

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. 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 https://www.raymondcamden.com

Comments