Mar 08

Remember CFHTMLHEAD ?

Posted by James Netherton | Thursday 08 March 2007 8:02 PM | In ColdFusion

I imagine it's a tag that doesn't get a great deal of usage (if any) in most people's applications. But it helped me turn what would have been a lengthy and laborious task, into a 1 minute fix.

I had a request to add some JavaScript code into the head section on a particular website. Trouble was, most of the pages were static and the page header content was hard coded across some 50 templates.

Naturally I didn't want to insert the same chunk of code into all of those templates, there's also so the potential to make mistakes with so many pages to alter.

Enter cfhtmlhead. The tag lets you insert content into the head section within a web page. So within my Application.cfm (or .cfc) I ended up with the following:

<cfhtmlhead text="<script language=""javascript"" type=""text/javascript"">my code here</script>"/>

The script then appears on all of my site pages. Obviously it's pretty simple to exclude the code from being output when you don't want it to be.

I know there are loads of other ways I could have achieved this but it seemed the most trouble and pain free at the time :)

 

0 Comments

[Post comment]


Leave a comment








Captcha text