overrideMimeType替代IE浏览器 [英] overrideMimeType alternative for IE

查看:153
本文介绍了overrideMimeType替代IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个问题,从来没有一个正确的答案,我有搜索很多次网和我不能找到一个解决方案。

  xhr.open(GET,fullurl,真正的);
如果(xhr.overrideMimeType)xhr.overrideMimeType(text / html的;字符集= ISO-8859-1);
xhr.send(空);

xhr.onreadystatechange =功能(){
如果(xhr.readyState == 4){
如果(xhr.status == 200)
警报(xhr.responseText);
 

它适用于火狐,Chrome。我的responseText将返回字符像留尼旺,这将表现为奇怪的符号。

我试了很多方法,如编码和解码,设定在响应文件头不工作。我出出主意。请帮助别人。


  **解决方案**
 

在你的主文件,请确保您设置的内容类型和字符集。

 < META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= ISO-8859-1/>
 

在您的AJAX加载网页,请确保您有这个顶部。

 标题(内容类型:text / html的;字符集= ISO-8859-1);
 

问题解决了,你一个快乐的人。这不再需要。

 如果(xhr.overrideMimeType)xhr.overrideMimeType(text / html的;字符集= ISO-8859-1);
 

解决方案

您不需要任何花哨像overrideMimeType。只要确保你的主要和AJAX加载网页的编码是(为preferrably UTF-8)正确。最有可能的,你都忘了 meta标签声明的编码。

This is a question that never has a proper answer, i have search the net many times and i couldnt find a solution.

xhr.open("GET", fullurl, true);
if(xhr.overrideMimeType) xhr.overrideMimeType("text/html; charset=ISO-8859-1");
xhr.send(null);

xhr.onreadystatechange  = function(){ 
if(xhr.readyState  == 4){
if(xhr.status  == 200) 
alert(xhr.responseText);

It works for firefox, chrome. My responseText will return char like Réunion, which will appear as weird symbols.

I tried many methods like encoding and decoding, setting header in response file which does not work. i'm out of ideas. Please help somebody.


**SOLUTION**

In your main file, make sure you set your content type and charset.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

In your AJAX-loaded page, make sure you have this at the top.

header('Content-Type: text/html; charset=iso-8859-1'); 

Problem solved, your a happy man. this is no longer needed.

if(xhr.overrideMimeType) xhr.overrideMimeType("text/html; charset=ISO-8859-1");

解决方案

You don't need anything fancy like overrideMimeType. Just make sure the encodings of your main and AJAX-loaded page are correct (preferrably UTF-8 for both). Most likely, you have forgotten the meta tag declaring the encoding.

这篇关于overrideMimeType替代IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆