Skip to main content
Participant
October 26, 2016
Answered

Detect Screen Width Cold Fusion 9

  • October 26, 2016
  • 2 replies
  • 2137 views

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 has been closed for replies.
Correct answer Steve Sommers

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.

2 replies

Participant
June 23, 2019

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.

WolfShade
Legend
October 26, 2016
Pam12345Author
Participant
October 26, 2016

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).

Steve SommersCorrect answer
Legend
October 26, 2016

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.