Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cfhtmlhead reset/unset or cancel?

Tags:

coldfusion

We have some ColdFusion apps that use the cfhtmlhead tag to add some scripts and random stylesheet link tags... problem is I can't change the files that do this, and my content has to execute along with the code that has the cfhtmlhead calls. Again, not much I can do to get around this.

The only thing I can think of that almost works is to do a <cfcontent reset="true"> which takes care of everything but the lingering <script>...</script> and <link ... /> tags that were added using <cfhtmlhead />

I just need to know if there is a way to reset or cancel anything that has been added via cfhtmlhead to output some text content that can't have script and link tags or any thing else littering the output.

From what I have tried/found, it doesn't seem possible. Can someone confirm if this is the case? Am I missing some simple or even hackish solution somewhere?

like image 913
John Avatar asked Mar 17 '26 05:03

John


2 Answers

Thanks to Henry's link and a few other issues I was figuring out at the same time, I got thinking of other ways to hack at it and found this simple solution that works for my original problem as I don't want/need to use content injected via the cfhtmlhead call at all:

<!--- output that doesn't work with the headerText being added to it --->
<cfsavecontent variable="dontLitter">
...
</cfsavecontent>

<cfcontent type="text/html" variable="#toBinary(toBase64(dontLitter))#" />

This works because when using the <cfcontent> tag with the variable attribute all previous output is discarded, including anything set with the <cfhtmlhead> - which is what was needed.

like image 117
John Avatar answered Mar 19 '26 01:03

John


while (getMetaData(out).getName() is 'coldfusion.runtime.NeoBodyContent')
{
    out = out.getEnclosingWriter();
}
methods = out.getClass().getDeclaredMethod("initHeaderBuffer",arrayNew(1));
methods.setAccessible(true);
methods.invoke(out,arrayNew(1));

http://www.coldfusiondeveloper.nl/post.cfm/clearing-the-cfhtmlhead-buffer-in-railo

like image 29
Henry Avatar answered Mar 19 '26 01:03

Henry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!