首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么CFHTMLHEAD不在ColdFusion 11中工作?

为什么CFHTMLHEAD不在ColdFusion 11中工作?
EN

Stack Overflow用户
提问于 2014-12-30 22:54:17
回答 1查看 1.2K关注 0票数 0

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

我继续读到从缺省值1024 SO增加Administrator > Server设置> Settings中的“最大输出缓冲区大小”,但是我尝试过的每一个值(2048 SO、4096 SO,甚至允许的最大值999999KB)都会得到相同的结果--当页面加载时,内容不包含在<HEAD>标记中。

还有其他人遇到这个问题并找到解决办法了吗?

代码示例:

htmlhead.cfm:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-23 00:35:05

我发现在CF11中,在cfcontent reset="true“之前使用cfhtmlhead调用添加的任何内容都不会添加到结果文档中。在您的cf_layout包含内容重置后调用的cf_htmlhead标记吗?

例如,

代码语言:javascript
复制
<!--- 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>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27713753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档