为什么CFHTMLHEAD无法在ColdFusion 11中运行?

时间:2014-12-30 22:54:18

标签: coldfusion coldfusion-11

到目前为止,我已经测试了几个页面,似乎无论我在哪里试图使用<CFHTMLHEAD>将CSS或JavaScript添加到ColdFusion 11中的CFM页面,它都不会添加它(在CF8中工作正常) )。

我在SO上读到有关增加管理员中的“最大输出缓冲区大小”的信息&gt;服务器设置&gt;默认值为1024KB的设置,但我尝试过的每个值(2048KB,4096KB,甚至最大允许999999KB)我都得到相同的结果 - 当页面加载时,内容未包含在<HEAD>标记中。

有没有其他人遇到这个并找到了解决方案呢?

代码示例:

htmlhead.cfm:

<cfif NOT ThisTag.HasEndTag>
    <cfthrow message="Missing end tag for custom tag htmlhead." type="HeadWrap" />
</cfif>

<cfif ThisTag.ExecutionMode is "End">
    <cfhtmlhead text="#ThisTag.GeneratedContent#" />
    <cfset ThisTag.GeneratedContent = "" />
</cfif>

index.cfm:

<cfsilent>
    <!--- 
        Data Retrieval, validation, etc. here
    --->

    <cf_htmlhead>
        <style type="text/css">
            tr.status-RETIRED td {
                color: #800000;
            }

            tr.status-PENDING td {
                color: #008000;
            }
        </style>
        <script type="text/javascript">
        $(function(){
            $(".options-menu").mouseleave(function(e){
                $(this).hide("fast");
            })

            $(".options-menu-link").mouseover(function(){
                $(".options-menu").hide("fast");

                $(".options-menu[data-sku='" + $(this).data("sku") + "']").show("fast");
            }).click(function(e){
                e.preventDefault();
            });
        });
        </script>
    </cf_htmlhead>
</cfsilent>

<!--- 
    Custom Tag layout.cfm contains the DOCTYPE declaration, html, head (loads jquery, jquery-ui, css, etc.), and body tags with a header and footer for each page.
--->
<cf_layout>
    <!--- Page Content Here (a form, a table, some divs, etc.) --->
</cf_layout>

1 个答案:

答案 0 :(得分:3)

我发现在CF11中使用cfhtmlhead调用添加的内容在cfcontent reset =&#34; true&#34;不会添加到生成的文档中。在cf_htmlhead包含内容重置后,您是否正在调用cf_layout标记?

例如,

<!--- This will not be added under CF11. --->
<cfhtmlhead text="<!-- I'm some content that will only be included in CF10 or lower. -->">

<cfcontent reset="true">

<!--- This will be added under CF11 and lower. --->
<cfhtmlhead text="<!-- I'm some content that will be added in CF11 and lower. -->">

... the rest of your view code ...

<!--- This is a sample of the content you will get under CF11 --->
<!doctype html>
<html>
<head>
   <meta charset="UTF-8" />
   <title>Head Testing</title>
      <!-- I'm some content that will be added in CF11 and lower. -->
   </head>
   <body>
      <h1>Page content</h1>
   </body>
</html>