javascript XML乱码
XML文件如下:<?xmlversion="1.0"encoding="gb2312"?><tableborder='1'><tbody><tr><th>哈哈</th><...
XML文件如下:
<?xml version="1.0" encoding="gb2312"?>
<table border='1'>
<tbody>
<tr>
<th>哈哈</th>
<th>哈哈</th>
<th>哈哈</th>
</tr>
<tr>
<td>Waterskiing</td>
<td>Dock #1</td>
<td>9:00 AM</td>
</tr>
<tr>
<td>Volleyball</td>
<td>East Court</td>
<td>2:00 PM</td>
</tr>
<tr>
<td>Hiking</td>
<td>Trail 3</td>
<td>3:30 PM</td>
</tr>
</tbody>
</table>
HTML文件如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if (window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("get", "innerHTML.xml", true);
xmlHttp.send(null);
}
function handleStateChange()
{
if (xmlHttp.readyState == 4){
document.getElementById('results').innerHTML = xmlHttp.responseText;
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value=" Search " onclick="startRequest()" />
</form>
<div id="results"></div>
</body>
</html>
中文全变成乱码了,请问各位前辈们,如何解决,谢谢了!
在火狐下正常, IE6下不正常 展开
<?xml version="1.0" encoding="gb2312"?>
<table border='1'>
<tbody>
<tr>
<th>哈哈</th>
<th>哈哈</th>
<th>哈哈</th>
</tr>
<tr>
<td>Waterskiing</td>
<td>Dock #1</td>
<td>9:00 AM</td>
</tr>
<tr>
<td>Volleyball</td>
<td>East Court</td>
<td>2:00 PM</td>
</tr>
<tr>
<td>Hiking</td>
<td>Trail 3</td>
<td>3:30 PM</td>
</tr>
</tbody>
</table>
HTML文件如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if (window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("get", "innerHTML.xml", true);
xmlHttp.send(null);
}
function handleStateChange()
{
if (xmlHttp.readyState == 4){
document.getElementById('results').innerHTML = xmlHttp.responseText;
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value=" Search " onclick="startRequest()" />
</form>
<div id="results"></div>
</body>
</html>
中文全变成乱码了,请问各位前辈们,如何解决,谢谢了!
在火狐下正常, IE6下不正常 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询