Javascript is client side and will only run in the browser, you cannot run
it from the server inside cfml.

so
<cfset session.screenwidth = "<script>document.write(
screen.width);</script>">
will simply assign the text  "<script>document.write(screen.width);</script>"
to session.screenwidth not the value your are expecting.

you need to run this script client side.
<script>document.write(screen.width);</script>

and then send the values back to the server, you could do this with ajax or
cookies.


On Sat, Dec 22, 2012 at 11:53 AM, The Dude <[email protected]> wrote:

>
> This should work nicely, tried out earlier today in Safari, Firefox and
> Chrome. Storing available vars in session for use throughout the app. My
> use case is loading a different include file that consumes smaller jpg
> files for a slider for mobile devices:
>
> <cfif Not IsDefined('session.screenwidth')>
>
> <cflock scope="session" type="exclusive" timeout="30">
> <cfset session.screenwidth =
> "<script>document.write(screen.width);</script>">
> <cfset session.screenheight =
> "<script>document.write(screen.height);</script>">
> <cfset session.availWidth =
> "<script>document.write(screen.availWidth);</script>">
> <cfset session.availHeight =
> "<script>document.write(screen.availHeight);</script>">
> <cfset session.colorDepth =
> "<script>document.write(screen.colorDepth);</script>">
> <cfset session.pixelDepth =
> "<script>document.write(screen.pixelDepth);</script>">
> </cflock>
>
> </cfif>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353605
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to