设置了utf—8,还是出现乱码 怎么办
这是网上读报纸的前台脚本代码,不知道为什么只有把浏览器里的查看设置成自动选择,网页才不会出现乱码。怎么才能不让他出现乱码 请各位大侠帮我看看。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"; content="text/html; charset="UTF-8"/>
<meta name="keywords" content="">
<style>
body{margin:0px;padding:0px;text-align:center;}
div{margin:0px auto;}
</style>
<script language="javascript" type="text/javascript">
Date.prototype.Format = function(formatStr)
{
var str = formatStr;
var Week = ['日','一','二','三','四','五','六'];
str=str.replace(/yyyy|YYYY/,this.getFullYear());
str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100));
str=str.replace(/MM/,this.getMonth()>9?this.getMonth().toString():'0' + this.getMonth());
str=str.replace(/M/g,this.getMonth());
str=str.replace(/w|W/g,Week[this.getDay()]);
str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
str=str.replace(/d|D/g,this.getDate());
str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours());
str=str.replace(/h|H/g,this.getHours());
str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes());
str=str.replace(/m/g,this.getMinutes());
str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds());
str=str.replace(/s|S/g,this.getSeconds());
return str;
}
var pram = window.location.search.indexOf("?")==-1?"1":window.location.search.split("=")[1];
function YYYYMMDDstart()
{
MonHead = [31,28,31,30,31,30,31,31,30,31,30,31];
today = new Date();
var zt;
if(today.getDay()==1){
if (today.getHours()>=17||(today.getHours()==16&&today.getMinutes()>=30))
{
zt=today;
}else{
zt=new Date(today.getTime()-86400000*2);
}
}else if(today.getDay()==0){
zt=new Date(today.getTime()-86400000);
}else {
if (today.getHours()>=17||(today.getHours()==16&&today.getMinutes()>=30))
{
zt=today;
}else{
zt=new Date(today.getTime()-86400000);
}
}
//var zt = new Date(today.getTime()-86400000);
var zt_Month = zt.getMonth()*1+1;
var zt_date = zt.getDate();
var y = zt.getFullYear();
for(var i = (y-10); i < (y+10); i++)
document.form1.YYYY.options.add(new Option(""+i+"",i));
//先给年下拉框赋内容
var y = zt.getFullYear();
for(var i = (y-10); i < (y+10); i++)
document.form1.YYYY.options.add(new Option(""+i+"",i));
//赋月份的下拉框
for(var i = 1; i<13; i++)
document.form1.MM.options.add(new Option(""+i+"", i));
//---------------------------
document.form1.YYYY.value = y; //获取到当前年份
document.form1.MM.value = zt_Month; //获取到当前月份
var n = MonHead[zt.getMonth()];
// if (zt.getMonth() ==1 &&
//alert(n);
//if (IsPinYear(YYYYvalue)) n++;
//alert("文本f");
//return;
//writeDay(n); //赋日期下拉框Author:meizz
MMDD(n);
//document.form1.DD.value = zt_date; //获取到当前日期
var n = MonHead[zt.getMonth()];
if (new Date().getMonth() ==1 && IsPinYear(YYYYvalue)) n++;
writeDay(n); //赋日期下拉框Author:meizz
var temp = "";
for(var j=0;j <new Date().getDate();j++){
var b=false;
var dete = new Date(new Date().setDate(new Date().getDate()-j));
switch(pram){
case "2":
if(dete.Format("w")=="六"){
document.form1.DD.value = dete.getDate(); //获取到当前日期
b=true;
}
break;
case "3":
if(dete.Format("w")=="日"){
document.form1.DD.value = dete.getDate(); //获取到当前日期
b=true;
}
break;
default:
if(dete.Format("w")!="六" && dete.Format("w") !="日") {
document.form1.DD.value = zt_date;
b=true;
}
break;
}
if(b) break;
}
var cend= 'http://hljfb.黑龙江新闻/'+y +''+(document.form1.MM.value.length==2?document.form1.MM.value:'0'+document.form1.MM.value)+''+(document.form1.DD.value>=2?document.form1.DD.value:'0'+ document.form1.DD.value);
checkme(cend+'/01-/01-_middle.jpg',cend+'/1/1_middle.jpg',cend+'/01/01_middle.jpg');
}
function YYYYDD(str) //年发生变化时日期发生变化(主要是判断闰平年)
{
var MMvalue = document.form1.MM.options[document.form1.MM.selectedIndex].value;
if (MMvalue == "")
{
var e = document.form1.DD;
optionsClear(e);
return;
}
var n = MonHead[MMvalue - 1];
if(MMvalue ==2 && IsPinYear(str)) n++;
writeDay(n)
}
function MMDD(str) //月发生变化时日期联动
{
var YYYYvalue = document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value;
if(YYYYvalue == "")
{
var e = document.form1.DD;
optionsClear(e);
return;
}
var n = MonHead[str - 1];
if (str ==2 && IsPinYear(YYYYvalue)) n++;
writeDay(n)
}
function writeDay(n) //据条件写日期的下拉框
{
var e = document.form1.DD; optionsClear(e);
var YY= document.form1.YYYY.value;
var MM=document.form1.MM.value;
for (var i=1; i<(n+1); i++){
var datee = new Date(YY,MM-1,i).Format("w");
switch(pram){
case "2":
if(datee=="六") e.options.add(new Option(""+i+"",i));
break;
case "3":
if(datee=="日") e.options.add(new Option(""+i+"",i));
break;
default:
if(datee!="六" && datee !="日") e.options.add(new Option(""+i+"",i));
break;
}
}
}
function IsPinYear(year)//判断是否闰平年
{
return(0 == year%4 && (year%100 !=0 || year%400 == 0));
}
function optionsClear(e)
{
for (var i=e.options.length; i>0; i--)
e.remove(i);
}
function SelectPic(day)
{
document.getElementById("pic").innerHTML= day +" 号的图!";
//alert(document.getElementById("pic"));
var cend= 'http://hljfb.黑龙江新闻/'+document.form1.YYYY.value +''+(document.form1.MM.value.length==2?document.form1.MM.value:'0'+document.form1.MM.value)+''+(document.form1.DD.value.length>=2?document.form1.DD.value:'0'+ document.form1.DD.value);
checkme(cend+'/01-/01-_middle.jpg',cend+'/1/1_middle.jpg',cend+'/01/01_middle.jpg');
}
function Redirect1()
{window.open('http://hljfb.');
return false;
}
function Redirect()
{
// var strurl = document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value+"/"+document.form1.MM.options[document.form1.MM.selectedIndex].value+"/"+document.form1.DD.options[document.form1.DD.selectedIndex].value+"/index.html";
// window.location.href= "hljxw"+"/"+strurl;
window.open('http://hljfb.黑龙江新闻/'+document.form1.YYYY.value +''+(document.form1.MM.value.length==2?document.form1.MM.value:'0'+document.form1.MM.value)+''+(document.form1.DD.value.length>=2?document.form1.DD.value:'0'+ document.form1.DD.value)+'/popup.htm');
return false;
}
function checkme(value1,value2,value3){
document.getElementById("pic").innerHTML='<img src="'+ value1 + '" width=\'400px\' height=\'600px\' onerror=\'checkus("'+ value2 + '","'+value3 + '")\' onclick="javascript:Redirect()">';
}
function checkus(value1,value2){
document.getElementById("pic").innerHTML='<img src="'+ value1 + '" width=\'400px\' height=\'600px\' onerror=\'checkend("'+value2 + '")\'>';
}
function checkend(value){
document.getElementById("pic").innerHTML='<img src="'+ value + '" width=\'400px\' height=\'600px\' onerror=\'document.getElementById("pic").innerHTML=""\'>';
}
</script>
</head>
<body onLoad="YYYYMMDDstart();">
<div id="pic" style="width:400px;height:600px;margin-top:0px;border:1px solid gray;display:inline-block"></div>
<div style="text-align:center;padding:10px">
<form name="form1">
<select name="YYYY" onChange="YYYYDD(this.value)">
<option value="0">选择年</option>
</select> 년
<select name="MM" onChange="MMDD(this.value)">
<option value="0">选择月</option>
</select> 월
<select name="DD" onChange="SelectPic(this.value)">
<option value="0">选择日</option>
</select> 일
<input type="button" onClick="return Redirect1();" value="도움말"/>
</form>
</div>
</body>
</html>
<!--Enorth webpublisher, Server name:NEN-RUPUBSYS, input mode: manual ,parse start at:2009-11-02 16:20:54 0 cost!-->
<!--Enorth webpublisher, Server name:NEN-RUPUBSYS, input mode: manual ,parse start at:2010-03-18 16:17:50 0 cost!-->