当我每10秒更新一次div的内容时,像ÆØÅ这样的特殊字符会成为问号。怎么了?这是我的代码:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#chat').load('#chat');
}, 10000); // refresh every 10000 milliseconds
</script>
<body>
<div id="chat">
<div class="melding">
<form action="chat.php?login=<?php echo $bruker; ?>" method="post">
<table>
<tr>
<td><input style="width: 420px;" type="text" name="melding"><input style="
border: 1px solid white;
background: #333;
color: white;"type="submit" name="send" value="Send"></td>
</tr>
</table>
</form>
<div style="color: white;">
<?php
$print = "SELECT * FROM chat WHERE (fra='$user' AND til='$bruker') OR (fra='$bruker' AND til='$user') ORDER BY id DESC LIMIT 100";
$resultat = mysql_query($print);
while($row = mysql_fetch_array($resultat)){
echo "<span class='red'>". nl2br(strip_tags($row['fra'])) .":</span> ". nl2br(strip_tags($row['melding'])) ."<br>";
}
?>
</div>
</div>
我的代码以UTF-8格式保存
答案 0 :(得分:1)
将此元标记添加到页面中:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
它告诉浏览器您提供的字符以UTF-8编码。 确保页面的其他内容也以UTF-8编码。