Search code examples
javascriptcoldfusionscreendetectionresponsive-design

coldfusion after screen size detection


I am making a responsive website and I want to be able to use javascript to get the screen size and then render a coldfusion include depending on the screen size. Something like this:

if (screen.width <= 700) {
     <cfinclude template="file1.cfm">
} else {
     <cfinclude template="file.cfm">
}

I've also tried loading via .ajax() but I get stuck when I have include files inside the cfm file in already want to include.


Solution

  • What you are trying to do is not possible. JavaScript is a client side language, ColdFusion is a server side language. You cannot do a cfinclude in a block of JavaScript as that code will be executed in the browser, not on the server.