I found the following javascript code to get the browser window size and it works great!
<script type="text/javascript">
<!--
var viewportwidth;
var viewportheight;
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
}
else
{
viewportwidth = document.body.clientWidth,
viewportheight = document.body.clientHeight
}
document.write('<p>Your viewport width is <b>'+viewportwidth+'x'+viewportheight+'</b>.</p>');
</script>
Now I need to pass it to the Grails controller so that I can resize the image to fit the screen size.
which is built using:
<div align="center" valign="middle">
<img src="${createLink(controller:'chart', action:'buildChart')}" />
</div>
How can i do this? Thanks in advance!
source
share