字符串"ďťż"随机出现在我的页面上,但只在firefox中.IE和chrome没有这个问题


The string "ďťż" appears on my page randomly but only in firefox. IE and chrome don't have this problem.

实际上在我的代码中没有打印任何东西。到目前为止,我只在两个地方发现了它,其中一个是:

<li class="spatiu"> </li>
<li class="memento_li"> 
    <div id="afisare_alerte">
    <script language="javascript">
        afisare_alerte_php();
    </script>
</div> 
</li>';

,这是"afisare_alerte_php() "

xmlhttp_alerte.onreadystatechange=function() {
    if (xmlhttp_alerte.readyState == 4) {                                               
         if(document.getElementById("afisare_alerte").innerHTML=xmlhttp_alerte.responseText){
         }
         schimbare_tip_cursor('default');
    }
    else{
        schimbare_tip_cursor('progress');
    }
};

是ajax的一部分。

它加载的文件是

<?php
    echo'
    0 Notificari
';
?>

和输出:

ďťż 0 Notificari

该序列ďťż称为Windows字节顺序标记。在大多数Windows程序中,当你将文件保存为UTF格式时,它就会显示出来。因此,这里的问题是必须从Windows服务器提供ajax端点,并且服务器被配置为输出BOM。如何解决这个问题取决于你使用的web服务器。

这些字符实际上确实存在于你的代码中,只是你看不到它们。一些编辑器在文件保存为UTF时添加了这些。要查看字符,请在仅支持iso的编辑器中打开代码(例如一个简单的记事本程序)。您将能够看到ďťż,然后您可以执行全局搜索/替换以删除它的所有实例。然后保存文件