既然是utf8,就不用bytes2BSTR(html)了
解决方案 »
- Jquery Ajax ie6下报参数无效异常··ie8,火狐测试好着
- 如何获取鼠标在页面上的坐标呢?搜到了一些代码,但是在Firefox都不行
- 能否实现对一个iframe内部超链接的捕获呢
- javascript中如何给表单名为变量的表单赋值
- 高分请教,在页面中如何实现反复提交用户名和密码的功能?
- 请问:从标题栏到网页正文之间的距离是多少啊,怎么表示?
- HTML+JavaScript里,当窗口大小改变后重刷本页,怎么实现?
- 很菜的问题,很容易拿的分!(提交确认)
- 如何decode url,(被多次encode)
- jQuery 对象构造问题
- http_request.responseText 不读PHP吗?
- 初学菜人请教!
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>怎么办?</title>
<SCRIPT LANGUAGE="VBSCRIPT">
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End FunctionFunction momoca(path,file,name,ext)
dim XmlHttp,url
url="/"+path+"/"+file+"."+ext
set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", url, false
XmlHttp.setRequestHeader "Content-Type","text/html; charset=utf-8"If xmlHttp.readyState < 4 then
eval("document.all."+name).innerHTML="loading...<br>页面载入中请等待..."
End IfXmlHttp.SendIf xmlHttp.readyState = 4 then
eval("document.all."+name).innerHTML="页面载入成功 —— by momcoa"
End Ifdim html
html = XmlHttp.responseBody
html = bytes2BSTR(html) //不管用不用这句,都不对.
eval("document.all."+name).innerHTML=html
End Function
</script></head><body>
<span id="momoca_1"></span>
<script language="javascript">momoca("modules/purchase/template","123","momoca_1","html");
///modules/purchase/template/123.html 这个页是一个UTF-8的页</script>
</body>
</html>
求求大家解决一下上吧.都是UTF-8的页为什么读出来 是乱码呢?
配置<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
并且发送的时候用
var str ="app="+encodeURI("中文");
xmlhttp.send(str)方式发送。
<%
Function getHTTPPage(url)
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
if instr(url,"http://")=0 then url="http://"&url
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
End function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Functionresponse.Write getHTTPPage("http://www.sina.com.cn/")
%>
Function BytesToBstr(body)
dim objstream
set objstream = Server.Create_Object("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "utf-8"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>用JS有办法实现吗?
想有A页读出B页的内容.
<SCRIPT LANGUAGE="VBSCRIPT">
dim XmlHttp,url
set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", "http://www.google.com/intl/zh-CN/", false
XmlHttp.setRequestHeader "Content-Type","text/html; charset=utf-8"
XmlHttp.Send
dim html
html = XmlHttp.responseBody
eval("document.all."+name).innerHTML=html
</SCRIPT>
<!--function zhiSelect(obj){
var r = document.selection.createRange();
r.moveToElementText(obj);
r.moveToPoint(event.x, event.y);
r.expand("word");
r.select();
}//-->
</SCRIPT>
<span id = "dictz_status" onmousemove="zhiSelect(this)">
但我想把它轉為..............
</span>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><script language="javascript">
var http_request = false;
function send_request(url) {//初始化、指定处理函数、发送请求的函数
http_request = false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest) { //Mozilla 浏览器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {//设置MiME类别
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { // IE浏览器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) { // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
//http_request.onreadystatechange = processRequest;
// 确定发送请求的方式和URL以及是否同步执行下段代码
http_request.open("GET", url, true);
http_request.send(null);
div1.innerHTML = http_request.responseText;
}
</script>
</head>
<body onload="send_request('http://www.google.com/intl/zh-CN/');"></body>
<div id=div1></div>
</html>
<body onload="send_request('http://alixixi.com/simplerss2.asp?fboardid=8&boardid=11');">