最近在做一个项目,因为页面使用了Cookie,所以要判断用户的浏览器是否支持Cookie,并提示用户如何开启浏览器的Cookie功能。同时,整个项目要配置多语言支持,包括中文、越南语、日语和英语,所以必须有语言配置文件。项目中应用jQuery解析读取XML语言配置文件来实现语言的调度。这是jQuery解析读取XML文件功能的测试源码,现拿出来分享。
目录结构: 
main.css文件代码:
@CHARSET “UTF-8”;
* {
margin: 0px;
padding: 0px;
}
body {
width: 800px;
text-align: left;
font-size:62.5%;
font: normal 0.75em tahoma, helvetica, sans-serif;
}
#Message_error {
height:16px;
color:#000;
line-height:16px;
background:#fcc url(image/msg_error.png) no-repeat;
margin-bottom:2px;
border-bottom:#faa 1px solid;
padding-left:20px;
overflow:hidden;
display:none;
}
#Message_success {
height:16px;
line-height:16px;
color:#000;
background:#cfc url(image/msg_success.png) no-repeat;
margin-bottom:2px;
border-bottom:#afa 1px solid;
padding-left:20px;
overflow:hidden;
display:none;
}
index.html文件代码:
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>jQuery行级读取XML文件</title>
<link rel=”stylesheet” href=”main.css” href=”main.css” type=”text/css”/>
<script type=”text/javascript” src=”jquery-1.3.2.js”></script>
<script type=”text/javascript” src=”browser.js” ><script>
</head>
<body>
<div id=”Message_success”></div>
<div id=”Message_error”></div>
</body>
</html>
MsgConfig_zh.xml文件代码:
<?xml version=”1.0″ encoding=”utf-8″?>
<Msg-Config>
<msg id=”1″ name=”cookie-support”>
<message>你的浏览器不支持Cookie,请开启浏览器的Cookie功能</message>
<message-help>点击查看开启Cookie方法</message-help>
<message-url>index.html</message-url>
</msg>
<msg id=”2″ name=”load-xml”>
<message>jQuery读取节点XML成功</message>
</msg>
</Msg-Config>
browser.js文件代码:
$(document).ready(function() {
/* Check the browser if open Cookie support.
* —————————————————– */
//navigator.cookieEnabled == true意为浏览器支持Cookie功能










