View comments | RSS feed

cfhtmlhead

Description

Writes text to the head section of a generated HTML page.

Category

Page processing tags

Syntax

<cfhtmlhead 
text = "text">

See also

cfcache, cfflush, cfheader, cfinclude, cfsetting, cfsilent

Attributes

Attribute Req/Opt Default Description

text

Required

 

Text to add to the <head> area of an HTML page.

Usage

Use this tag for embedding JavaScript code, or putting other HTML tags, such as meta, link, title, or base in an HTML page header.

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

Example

<!--- This example adds a favicon to the HTML 
 Head of every page view. The extra CRLF at 
 the end cleans up view source. Note the 
 embedded tag uses double quotes and the cfhtmlhead 
 text attribute uses single quotes, 
 but it could be the other way around too. 
--->

<cfhtmlhead 
    text='<link href="/blog/custom/img/favicon.ico" rel="shortcut icon" type="image/x-icon">#chr(13)##chr(10)#'>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


frinky!!! said on Jul 12, 2007 at 2:54 AM :
I have searched all over, but never found a solution to this question: is it possible to eliminate the contents of a cfhtmlhead-text after it is set?
For instance, a <cfhtmlhead text="<meta name='author' value='very important person' />" /> is set in Application.cfm, but some of the pages within the app output xml content. In that case, the xml will not validate, because CF will put the meta tag on top of the outputted xml.
I have tried ClearBuffer() and getResponse.reset() from the getPageContext(), but the cfhtmlhead-text still remains.


How can I remove it, or at least: where is the cfhtmlhead data stored?
frinky!!! said on Jul 13, 2007 at 3:20 AM :
Already found the solution to my previous question, as can be found here: http://www.bennadel.com/index.cfm?dax=blog:758.view#comments_4523
The function to clear the cfhtmlhead contents is: (made by Elliott Sprehn)
<cfscript>
function resetCFHtmlHead() {
var out = getPageContext().getOut();
var method = out.getClass().getDeclaredMethod("initHeaderBuffer",arrayNew(1));
method.setAccessible(true);
method.invoke(out,arrayNew(1));
}
</cfscript>
But it's much better to read the posts first :)

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000271.htm