Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Detect Screen Width Cold Fusion 9

Community Beginner ,
Oct 26, 2016 Oct 26, 2016

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?

2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 26, 2016 Oct 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.

Translate
LEGEND ,
Oct 26, 2016 Oct 26, 2016
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2016 Oct 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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 26, 2016 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 26, 2016 Oct 26, 2016

It seems to me like you are trying to use a server side process to do something that belongs in the UI.  As Steve suggests, you should really get a better understanding of JS and handle the issue there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2016 Oct 26, 2016

Thank you for your time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2019 Jun 23, 2019
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources