Cool little CFPOD Trick

This post is more than 2 years old.

During my presentation on Wednesday concerning Ajax and ColdFusion 8, someone asked about degradation when JavaScript was turned off. What I had said was that I had not tested it, but I assumed that while stuff would render, anything dynamic would not work, including remote content. So for a text I showed this:

<cfpod source="test2.cfm" test="Status" />

I loaded it up in the browser and confirmed that test2.cfm loaded. I then disabled JavaScript and reloaded the page. The pod rendered just fine, but was now empty.

Now for the cool part. I changed my code to:

<cfpod source="test2.cfm" title="Status"> You need to enable JavaScript. </cfpod>

I reloaded the page and there was my warning. I re-enabled JavaScript, reran the page, and test2.cfm showed up! You could, in theory, use this for simple JavaScript detection. If test2.cfm had a cflocation in it, you could then use this code to warn the user that they must enable JavaScript to continue. Not sure if that is a great idea - but it seemed like a neat trick.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA