September 25, 2006

cfhtmlhead

Sometimes during development you may want to programmatically add text/content to the <head> area of the currently processing page. Most often I do this when I want to add Javascript code or link tags dynamically.

<cfhtmlhead> is a great tool to use for this as you don’t need to try and spaghetti code your header include/module.

For example:

<cfhtmlhead text="<script type="text/javascript" src="/js/myScript.js"></script>">

TEXT

The text you want to add to the <head> area of an HTML page. Everything inside the quotation marks is placed in the <head> section.

Note that if you use this tag after the cfflush tag on a page, an error is thrown.

© Michael Sharman 2017