Skip to main content
Participant
Oct 26, 2016 3:30 PM UTC
Answered

Detect Screen Width Cold Fusion 9

We are trying to execute a cfinclude determined by screen width on our responsive website. This if for determining the number of ads that will appear on the page (we want to show a fixed number on screens of 700px or less). We are using Cold Fusion 9 so we can't utilize CF 11's detectDevice function. We realize we can't just use media queries to show or hide the appropriate cfinclude because this will not prevent CF from loading unnecessary ads in the background, it will just hide them and our page speed will be affected. Is Javascript the only way to do this? If so, can someone provide an example without Jquery?

This topic is closed to new replies. Start a new post to keep the conversation going.
Steve SommersCorrect answer
Legend
Oct 26, 2016 4:36 PM UTC

I would suggest either learning javascript or better yet, learn javascript and incorporate a responsive framework like bootstrap 3. Trust me, maintaining width specific include modules on the server will rapidly become a nightmare for you or whoever inherits the project.

6 replies

Participant
Jun 23, 2019 9:38 PM UTC

There is a way to do it in ColdFusion 2018.

<cfclientsettings detectDevice=true />

<cfclient>

<cfif cfclient.properties.width lte 480>

Be aware that the Adobe documentation has a typo "cfclient.width" leaving the "properties" out.

Translate
WolfShade
Legend
Oct 26, 2016 3:58 PM UTC
Pam12345Author
Participant
Oct 26, 2016 4:20 PM UTC

We are novices when it comes to javascript. We see plenty of examples on how to determine width with javascript but we're not sure what exactly we are doing with that information; how we are showing cfinclude 1 for 700px or less and cfinclude 2 for everything else. We were hoping there was another way to do this with just Cold Fusion (9).

Translate
Steve SommersCorrect answer
Legend
Oct 26, 2016 4:36 PM UTC

I would suggest either learning javascript or better yet, learn javascript and incorporate a responsive framework like bootstrap 3. Trust me, maintaining width specific include modules on the server will rapidly become a nightmare for you or whoever inherits the project.

Translate