>
> Thanks for further inputs.
>
Play with this code a bit.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function Box(){
var viewportwidth;
var viewportheight;
// the more standards compliant browsers
(mozilla/netscape/opera/IE7)
use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}
// IE6 in standards compliant mode (i.e. with a valid
doctype as the
first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth
!= 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
}
// older versions of IE
else
{
viewportwidth =
document.getElementsByTagName('body')[0].clientWidth,
viewportheight =
document.getElementsByTagName('body')[0].clientHeight
}
alert('Your viewport dimension is '+viewportwidth+' x
'+viewportheight+' pixels');
document.cookie =
'windim='+viewportwidth+'|'+viewportheight+';
expires=Fri, 24 Oct 2008 00:00:00 UTC; path=/';
}
//-->
window.onload = Box();
</script>
</head>
<body>
<cfoutput>
<h1>Fun with window sizes</h1>
Diminsion Cookie
<cfif structKeyExists(cookie,"windim")>
<p>Your viewport dimension is
#listFirst(cookie.windim,'|')# x
#listLast(cookie.windim,'|')# pixels</p>
</cfif>
<p><a href="#cgi.SCRIPT_NAME#">Click here to
update windows
diminsion.</a></p>
</cfoutput>
</body>
It is important to note the order of things. When this page
is first
ran the JavaScript gets the dimensions and writes the
cookies.
When it is run again ColdFusion reads the cookies that from
the previous
request and then the client gets it and runs the JavaScript
again
updating the cookie.
I.E. JavaScript is always outputting the current dimensions,
ColdFusion
is output the *last* dimensions. Play with this page by
changing the
browser size and then clicking on the link.
If you wanted more immediate feed back replace the
document.cookie line
in the javascript with a call to a ajax function that sends a
request
immediately to the server.
It'll have to wait for different day for me to have time to
whip up an
example like that.