2

私は CakePhp 2.0 に奇妙なエラーがあり、head タグが空でレンダリングされ、head に属するすべてのタグがコンテンツの前に body にレンダリングされます。

これは、レイアウトの default.ctp がどのように見えるかを示しています。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php echo $this->Html->charset(); ?>
    <title>
        <?php echo $title_for_layout; ?>
    </title>
    <?php
        echo $this->Html->meta('icon');
        echo $this->Html->script(array('librerias/jquery.tools.min'));
        echo $this->Html->css('cake.generic');
        echo $this->Html->css('webfront');
        echo $scripts_for_layout;
    ?>
</head>
<body>
    <div id="container">
        <div id="header">
        </div>
(the rest of the html render)
</body>
</html>

firebug が言うように、これはそれがどのようにレンダリングされるかです:

<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
&#65279;&#65279;
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title> Usuarios </title> **(IE moves the title tag on the head manually, it seems)**
    **(IE displays the DOCTYPE on its debugging console here)**
    <link rel="icon" type="image/x-icon" href="/web/favicon.ico">
    <link rel="shortcut icon" type="image/x-icon" href="/web/favicon.ico">
    <script src="/web/js/librerias/jquery.tools.min.js" type="text/javascript">
    <link href="/web/css/cake.generic.css" type="text/css" rel="stylesheet">
    <link href="/web/css/webfront.css" type="text/css" rel="stylesheet">
    <div id="container">
        <div id="header"> </div>
        (the rest of the html render)
</body>
</html>

DOCTYPE タグを歪め、IE がページを非常にバグのあるものにレンダリングするため、これは十分に悪いことです。

また、このエラーが発生しない別のテスト サイトがあります。実際、レイアウトを切り替えましたが、エラーは同じでした。

誰かがなぜこれが起こるのか知っていますか? ウェブ上で同様のものを見つけることができず、これについての手がかりもありません。どんな助けでも大歓迎です。

前もって感謝します

4

3 に答える 3

1

BOM char のファイルがあります。BOM 検出プログラムを使用する

java : http://www.javapractices.com/topic/TopicAction.do?Id=257 [推奨][見つけて削除]

1- 存在する BOM の URL を確認します
2- ファイルから BOM を削除します
php : http://www.dotvoid.com/2010/04/detecting-utf-bom-byte-order-mark/

于 2014-03-13T08:09:35.030 に答える
0

レイアウト ファイルに終了タグが 1 つありません。

    <body>
        <div id="container">
            <div id="header">
            </div>
    (the rest of the html render)
    </body>
    </html>

次のように修正する必要があります

    <body>
        <div id="container">
            <div id="header">
            </div>
    (the rest of the html render)
        </div>
    </body>
    </html>
于 2012-05-05T05:45:59.207 に答える