首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

处女帖 JS代码在FF浏览器下失效,请JAVA高手帮忙看看解决思路

2012-05-28 
处女帖 JS代码在FF浏览器下失效,请JAVA高手帮忙看看HTMLHEADlink IDskin relstylesheet type

处女帖 JS代码在FF浏览器下失效,请JAVA高手帮忙看看
<HTML>
<HEAD>
<link ID="skin" rel="stylesheet" type="text/css">


<TITLE>换肤</TITLE>

</HEAD>
<BODY>
<P>请选择下面的下拉菜单测试换肤效果</P>
<a href=# onClick="changecss('css.css')">css.css</a>
<a href=# onClick="changecss('css1.css')">css1.css</a>
<a href=# onClick="changecss('css2.css')">css2.css</a>
<a href=# onClick="changecss('css3.css')">css3.css</a>
<br>



 <SCRIPT LANGUAGE=javascript>
<!--
function SetCookie(name,value){
var argv=SetCookie.arguments;
var argc=SetCookie.arguments.length;
var expires=(2<argc)?argv[2]:null;
var path=(3<argc)?argv[3]:null;
var domain=(4<argc)?argv[4]:null;
var secure=(5<argc)?argv[5]:false;
document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
function GetCookie(Name) {
var search = Name + "=";
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) { 
offset += search.length;
end = document.cookie.indexOf(";", offset); 
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}
}
return returnvalue;
}
var thisskin;
thisskin=GetCookie("nowskin");
if(thisskin!="")
skin.href=thisskin;
else
skin.href="css.css";
function changecss(url){
if(url!=""){
skin.href=url;
var expdate=new Date();
expdate.setTime(expdate.getTime()+(24*60*60*1000*30));
//expdate=null;
//以下设置COOKIES时间为1年,自己随便设置该时间..
SetCookie("nowskin",url,expdate,"/",null,false);
}
}
//-->
</SCRIPT>

</div>
</BODY>
</HTML>




上面这段代码。头部不加<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 则在FF浏览器下一切正常,加了就失效。查了下,FF浏览器是严格遵守W3C标准的。 特在此请高人帮改下JAVA代码,使之符合W3C标准。

[解决办法]

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><HTML><HEAD><link ID="skin" rel="stylesheet" type="text/css"><TITLE>换肤</TITLE></HEAD><BODY><P>请选择下面的下拉菜单测试换肤效果</P><a href=# onClick="changecss('css.css')">css.css</a><a href=# onClick="changecss('css1.css')">css1.css</a><a href=# onClick="changecss('css2.css')">css2.css</a><a href=# onClick="changecss('css3.css')">css3.css</a><br> <SCRIPT LANGUAGE=javascript><!--var skin = document.getElementById('skin')function SetCookie(name,value){var argv=SetCookie.arguments;var argc=SetCookie.arguments.length;var expires=(2<argc)?argv[2]:null;var path=(3<argc)?argv[3]:null;var domain=(4<argc)?argv[4]:null;var secure=(5<argc)?argv[5]:false;document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");}function GetCookie(Name) {var search = Name + "=";var returnvalue = "";if (document.cookie.length > 0) {offset = document.cookie.indexOf(search);if (offset != -1) {  offset += search.length;end = document.cookie.indexOf(";", offset);  if (end == -1)end = document.cookie.length;returnvalue=unescape(document.cookie.substring(offset,end));}}return returnvalue;}var thisskin;thisskin=GetCookie("nowskin");if(thisskin!="")skin.href=thisskin;elseskin.href="css.css";function changecss(url){if(url!=""){skin.href=url;var expdate=new Date();expdate.setTime(expdate.getTime()+(24*60*60*1000*30));//expdate=null;//以下设置COOKIES时间为1年,自己随便设置该时间..SetCookie("nowskin",url,expdate,"/",null,false);}}//--></SCRIPT></div></BODY></HTML> 

热点排行