求助:关于中文乱码 100分 <meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">实际上这里并没有起作用,因为他是IE装载完网页之后才写出来的,IE没有解释它。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 临时做的,见笑了。<script>function trans(str){var reg=/[^\x00-\xff]/gvar idx=0,ret="";while(reg.exec(str)){ret+=str.substring(idx,RegExp.lastIndex-1)+"&#"+RegExp.lastMatch.charCodeAt(0)+";"idx=RegExp.lastIndex;}ret+=str.substring(idx)return(ret);}var NewWindow = window.open("about:blank", "displayNode");var doc = NewWindow.document;doc.open();doc.writeln(trans("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>"));doc.writeln(trans("<body>中文内容</body></html>"));</script> 有效的办法就是,不要用document.write写。<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">我的感觉,页面meta只有在网页装载的时候会被解释,如果document.write语句执行的时候meta可以被解释的话,那就正确了(因为meta就是用来告诉浏览器我这个页面字符集是gb2312的),不然肯定会出错,从你有过出错,得出结论document.write时候没有解释meta,其实你完全没有必要使用document.write,试试这个NewWindow.document.body.innerHTML,这样做跟那个效果是一样的。<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"><title>中文标题</title></head><body>中文内容</body></html> 还是不行,body is not a object. <BODY></BODY><script>document.body.innerHTML = "<font color=red>test</font>"</script>???? 关于iFrame自适子页的高度,在线等,,, 急!!!!JS中定义三维变量问题 select框大小不断变化,求解决办法 关于jquery select的问题 没明白 用javascript处理用户输入的字符串,如何转化危险字符? ASP.NET调用JavaScript 用js怎样将地址栏、状态栏等去掉。条件是:不用window.open(),因为我不打开新页面,只是在本页面控制。 关于延迟问题 关于Select的option的问题!!!!!!!!!!! js的运算问题?(费解,急!) 求助:下拉菜单在本窗口打开
function trans(str){
var reg=/[^\x00-\xff]/g
var idx=0,ret="";
while(reg.exec(str)){
ret+=str.substring(idx,RegExp.lastIndex-1)+"&#"+RegExp.lastMatch.charCodeAt(0)+";"
idx=RegExp.lastIndex;
}
ret+=str.substring(idx)
return(ret);
}var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln(trans("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>"));
doc.writeln(trans("<body>中文内容</body></html>"));
</script>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
我的感觉,页面meta只有在网页装载的时候会被解释,如果document.write语句执行的时候meta可以被解释的话,那就正确了(因为meta就是用来告诉浏览器我这个页面字符集是gb2312的),不然肯定会出错,从你有过出错,得出结论document.write时候没有解释meta,其实你完全没有必要使用document.write,试试这个NewWindow.document.body.innerHTML,这样做跟那个效果是一样的。<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>中文标题</title></head>
<body>中文内容</body>
</html>
<script>
document.body.innerHTML = "<font color=red>test</font>"
</script>????