DevWebProSE
DevWebProSE Newsletter:
Last Updated:


Get Your Site Submitted for Free in the World's Largest B2B Directory!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions


Sizing A Window With ColdFusion

By Raymond Camden
Expert Author
Article Date: 2007-05-08

Jay asks:

OK, I should know how to do this and I feel stupid for asking but I am going to anyway.

Is there a simple way in Coldfusion to grab the current size of the window you have opened?
This isn't stupid - but is one of the many questions that reveal that you may have forgotten that ColdFusion is completely server side. ColdFusion's only interaction with the browser is with the HTML returned via the web server.

So with that being said, you can use JavaScript to check the size of the window. I found a few methods, but these properties seem to work fine in Firefox. (And I'm too lazy to start Parallels just for IE, so I'm fine with people correcting me.)

window.outerWidth
window.outerHeight


You can check these values and if they are too small, resize the window. Consider this complete example:

<html>

<head>
<title>Min Size Test</title>
<script>
function checkMinSize() {
   if(window.outerWidth < 500) window.resizeTo(500, window.outerHeight);
   if(window.outerHeight < 500) window.resizeTo(window.outerWidth,500);
}
</script>
</head>

<body onLoad="checkMinSize()">

</body>
</html>


All this does is check the width and height. If either are less then 500 pixels, the window is resized to the correct size. I do this in two steps because it is possible only one dimension is too small.

Comments

About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com

Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.



Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact | Site Map

DevWebProSE is an iEntry, Inc.® publication - 1998-2008 All Rights Reserved Privacy Policy and Legal