2
页发送如下:如何解决这个字符编码问题?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script>
function send() {
var chinese = document.getElementById('chinese').value;
window.location = 'receive.html?' + chinese;
}
</script>
</head>
<body>
<input id="chinese" type="text" name="chinese" value="" />
<button onclick="send()">Submit</button>
</body>
</html>
接收页面如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script>
window.onload = function() {
var chinese = location.search;
document.getElementById('chinese').value = chinese;
}
</script>
</head>
<body>
<input id="chinese" type="text" name="chinese" value="" />
</body>
</html>
的问题是,接收页面不接收/正确显示中国汉字。例如,它将显示?%E9%A6%96%E9%A1%B5
,而不是首页
,虽然它在浏览器地址栏的查询字符串中显示得很好。