嵌套 html 中的字符集更改
Charset changes in nested html
我使用 jQuery.load(test.html)
加载了一个 HTML 文件。但是当我这样做时,字符集从 UTF-8 更改为不知道元音变音符 (ä,ö,ü) 的内容。根 HTML 文件中的文本显示正确。
我的 header 在根 html-file 中是:
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotspot Nöttingen</title>
<meta name="description" content="Alle Termine, Berichte und Aktuelles vom Hotspot" />
<meta name="keywords" content="just, some, keywords" />
<meta name="language" content="de" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" media="(max-width: 500px)" href="css/mobile.css" />
<link rel="stylesheet" type="text/css" media="(min-width: 500px)" href="css/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
child html-file 开头为:
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="de" />
</head>
编辑: 我现在使用 $.ajaxSetup()
在加载前设置字符集:
// Load site
$.ajaxSetup({
"beforeSend" : function(xhr) {
xhr.overrideMimeType("text/html; charset=UTF-8");
},
});
$("#load_container").load(site, function() {
$(".pending").hide();
});
这是我得到的:
您是否有权更改子 html 文件的编码类型。
我终于弄明白问题出在哪里了:
我使用 Notepad++ 和 ANSI 编写了 child HTML。但是根 HTML 是用 UTF-8 编写的。所以问题出在编辑器设置上。
我使用 jQuery.load(test.html)
加载了一个 HTML 文件。但是当我这样做时,字符集从 UTF-8 更改为不知道元音变音符 (ä,ö,ü) 的内容。根 HTML 文件中的文本显示正确。
我的 header 在根 html-file 中是:
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotspot Nöttingen</title>
<meta name="description" content="Alle Termine, Berichte und Aktuelles vom Hotspot" />
<meta name="keywords" content="just, some, keywords" />
<meta name="language" content="de" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" media="(max-width: 500px)" href="css/mobile.css" />
<link rel="stylesheet" type="text/css" media="(min-width: 500px)" href="css/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
child html-file 开头为:
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="de" />
</head>
编辑: 我现在使用 $.ajaxSetup()
在加载前设置字符集:
// Load site
$.ajaxSetup({
"beforeSend" : function(xhr) {
xhr.overrideMimeType("text/html; charset=UTF-8");
},
});
$("#load_container").load(site, function() {
$(".pending").hide();
});
这是我得到的:
您是否有权更改子 html 文件的编码类型。
我终于弄明白问题出在哪里了:
我使用 Notepad++ 和 ANSI 编写了 child HTML。但是根 HTML 是用 UTF-8 编写的。所以问题出在编辑器设置上。