不要用document.write用下面这种方式:<script type="text/javascript"> var timeele=document.createElement("span"); timeele.style.fontSize="30px";//设置字体大小 timeele.innerHTML="你要输出的文本或数字"; document.body.appendChild(timeele); </script>
<style type="text/css"> <!-- .myText {font-size: 12px} --> </style> <SCRIPT> <!-- todayDate = new Date(); date = todayDate.getDate(); month= todayDate.getMonth() +1; year= todayDate.getYear(); document.write("<span class=\"myText\">") if(navigator.appName == "Netscape") { document.write(1900 + year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日 "); } if(navigator.appVersion.indexOf("MSIE") != -1) { document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日 "); } if (todayDate.getDay() == 5) document.write("星期五"); if (todayDate.getDay() == 6) document.write("星期六"); if (todayDate.getDay() == 0) document.write("星期日"); if (todayDate.getDay() == 1) document.write("星期一"); if (todayDate.getDay() == 2) document.write("星期二"); if (todayDate.getDay() == 3) document.write("星期三"); if (todayDate.getDay() == 4) document.write("星期四"); document.write("</span>") //--> </SCRIPT>
var str="2008年9月9日 星期二 "; var span=document.createElement("<span style='font-size:8px;'>"); span.innerHTML=str; document.body.appendChild(span); 把日期生成字符串后str后填充就可以了
var timeele=document.createElement("span");
timeele.style.fontSize="30px";//设置字体大小
timeele.innerHTML="你要输出的文本或数字";
document.body.appendChild(timeele);
</script>
<!--
.myText {font-size: 12px}
-->
</style>
<SCRIPT>
<!--
todayDate = new Date();
date = todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("<span class=\"myText\">")
if(navigator.appName == "Netscape") {
document.write(1900 + year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日 "); }
if(navigator.appVersion.indexOf("MSIE") != -1) {
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日 ");
}
if (todayDate.getDay() == 5)
document.write("星期五");
if (todayDate.getDay() == 6)
document.write("星期六");
if (todayDate.getDay() == 0)
document.write("星期日");
if (todayDate.getDay() == 1)
document.write("星期一");
if (todayDate.getDay() == 2)
document.write("星期二");
if (todayDate.getDay() == 3)
document.write("星期三");
if (todayDate.getDay() == 4)
document.write("星期四");
document.write("</span>")
//-->
</SCRIPT>
var str="2008年9月9日 星期二 ";
var span=document.createElement("<span style='font-size:8px;'>");
span.innerHTML=str;
document.body.appendChild(span);
把日期生成字符串后str后填充就可以了