js window.open 弹出窗口设置 UTF-8编码的问题解决

来源:互联网 发布:写出数据库的关系模式 编辑:程序博客网 时间:2024/06/02 06:59

js window.open 弹出窗口设置 UTF-8编码的问题解决

发现弹出空白窗口时,页面为unicode编码,查询了下,发现document.write默认使用unicode编码。后来可以用pwin.document.charset=”UTF-8″;语句来解决编码问题。
 function log() {
var newwindow=window.open('about:blank'); 
var printerCode = $("#printerCode").val();
var logUrl= getRootPath().replace("HsCloudPrint","") + "HsFiles/logFiles/"+printerCode+".log";
 htmlobj=$.ajax({url:logUrl,type:"get", contentType: "application/x-www-form-urlencoded; charset=utf-8", async:false});
if(htmlobj.status=="200"){
newwindow.document.write(htmlobj.responseText);
newwindow.document.charset="UTF-8";
}else{
newwindow.close(); 
}
}
0 0
原创粉丝点击