One good example.  And one bad example (of side effects)

1 Good example

suppose you are writing this custom tag and you would like to have a piece
of <script> appear in the <head></head> area, just to be nice and orderly.
Well, use <cfhtmlhead>.  You have no access to the main page positioning
otherwise, unless you are also the owner of the main page calling your
custom tag.

This is in fact what happens when you use <cfinput validate="date"> for
example.  cfinput internally must use <cfhtmlhead>.  Magically it appears in
your code in the right place (use view source and you will see.)

Nice!

2. Bad example

Nothing too bad, you just need to be aware of the side effect.

What CF seems to do is keep this text buffer you specify, and hold it until
the last part of the CF processing.  When all is done, CF will scan the
output stream for the LAST </head> in the code and insert this buffer RIGHT
THERE.  The problem is, if you are doing syndication and grabbing html
contents from another place, it may come with <head></head> itself without
you even knowing it.  It usually does not matter to IE or Netscape.  But it
matters to CF.

see this:

<cfquery name="foo" datasource="whatever">select bigtext from contenttable
whereid=1</cfquery>
<html>
<head></head>
<body>
  <table>
    <tr>
      <td>
        <cfoutput>#foo.bigtext#</cfoutput>  <---- here is the problem
      </td>
    </tr>
  </Table>
</body>
</html>

If by any chance #foo.bigtext# contains something that looks like a </head>
it will insert your code there!  I even tried <!--</head>--> in the database
and it stills puts the code inside the comment.

I suspect that this multiple pass to the output stream is partially at fault
of why CF cannot flush the output while it is produced, the way ASP does it,
sending chunks of output while process is still pending.  It needs the whole
string first.

<Jaime/>



> -----Original Message-----
> From: wpdd [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 05, 2000 10:40 AM
> To: CF-Talk
> Subject: <cfhtmlhead>
>
>
> Does anyone examples of good uses for this tag ?
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to