Javascript+css ʵÏÖÍøÒ³»»·ô¹¦ÄÜ
ÏÖÔÚÍøÕ¾»»Æ¤·ôÊDZȽϳ£¼ûµÄ¹¦ÄÜ£¬´ó¶àÊýÂÛ̳¶¼Óеģ¬ÒªÏëʵÏÖÕâÑùЧ¹û¿ÉÒÔ¿´ÈçÏ´úÂ룺Html´úÂ벿·Ö:
1.ÒªÓÐÒ»¸ö´øidµÄÑùʽ±íÁ´½Ó,ÎÒÃÇҪͨ¹ý²Ù×÷Õâ¸öÁ´½ÓÀ´µ÷Óò»Í¬µÄhref.
<link href="css/main0.css" rel="stylesheet" type="text/css" id="cssfile" />
2.Ƥ·ôÑ¡Ôñ°´Å¥(ºǫ́Ϊÿ¸öliÌí¼Óonclickʼþ,´¥·¢»»·ô¹¦ÄÜ)
<ul id="skin">
<li id="skin_0" title="»ÒÉ«">»ÒÉ«</li>
<li id="skin_1" title="ÂÌÉ«">ÂÌÉ«</li>
<li id="skin_2" title="»ÆÉ«">»ÆÉ«</li>
<li id="skin_3" title="À¶É«">À¶É«</li>
<li id="skin_4" title="·ÛÉ«">·ÛÉ«</li>
<li id="skin_5" title="×ÏÉ«">×ÏÉ«</li>
</ul>
Js²¿·Ö:
1.»»·ô·½·¨
//ÉèÖÃcookie,°´Å¥Ñ¡ÖÐ״̬,Ò³ÃæƤ·ô
skin.setSkin=function(n){
var skins =("skin").getElementsByTagName("li");
for (i=0;i<skins.length;i++)
{
skins[i].className="";//³õʼ»¯°´Å¥×´Ì¬
}
skin.setCookie(n);//±£´æµ±Ç°Ñùʽ
("skin_"+n).className="selected";//ÉèÖÃÑ¡ÖÐƤ·ô°´Å¥µÄÑùʽ
("cssfile").href="css/main"+n+".css";//ÉèÖÃÒ³ÃæÑùʽ
}
2.´æÈ¡cookie
//½«µ±Ç°Æ¤·ôn´æµ½cookie
skin.setCookie=function(n){
var expires=new Date();
expires.setTime(expires.getTime()+24*60*60*365*1000);
var flag="Skin_Cookie="+n;
document.cookie=flag+";expires="+expires.toGMTString();
}
//·µ»ØÓû§ÉèÖõÄƤ·ôÑùʽ
skin.readCookie=function(){
var skin=0;
var mycookie=document.cookie;
var name="Skin_Cookie";
var start1=mycookie.indexOf(name+"=");
if(start1==-1){
skin=0;//Èç¹ûûÓÐÉèÖÃÔòÏÔʾĬÈÏÑùʽ
}
else{
var start=mycookie.indexOf("=",start1)+1;
var end=mycookie.indexOf(";",start);
if(end=-1){
end=mycookie.length;
}
var values= unescape(mycookie.substring(start,end));
if (values!=null)
{
skin=values;
}
}
return skin;
}
3.°ó¶¨»»·ô°´Å¥Ê¼þ
skin.addEvent=function(){
var skins =("skin").getElementsByTagName("li");
for (i=0;i<skins.length;i++)
{
skins[i].onclick=function(){skin.setSkin(this.id.substring(5))};
}
}
4.Ò³Ãæ¼ÓÔØÍê³ÉºóÉèÖÃƤ·ôÑùʽ
window.onload=function(){
skin.setSkin(skin.readCook
Ïà¹ØÎĵµ£º
JavaScript¶¯Ì¬Ìí¼Óɾ³ý±í¸ñÐÐ(Ö§³ÖFireFox)
2006-08-16 12:47
¡¡¡¡Ð§¹ûͼÈçÏ£º
¡¡¡¡µã“Ìí¼Ó²ÎÓëÈË”°´Å¥¿ÉÒÔÌí¼ÓÒ»ÐУ¬Ã¿ÐкóÃ涼ÓÐÒ»¸öɾ³ý°´Å¥£¬¿ÉÒÔɾ³ýËùÔÚÐУ¬“Çå¿Õ”Ôòɾ³ýËùÓеÄÐС£
¡¡¡¡ÕâÖÖЧ¹ûÔÚÐèÒªÅúÁ¿Ìí¼ÓÊý¾ÝµÄʱºò·Ç³£ÓÐÓ㬿ÉÒÔÔÚ¿Í»§¶ËÌí¼ÓÍêÒ»ÅúÊý¾Ý£¬È»ºóͨ¹ýAJAXÒ»´ÎÌá½ ......
1. document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ ......
Çó 555.555µÄËÄÉáÎåÈë±£ÁôÁ½Î»Ð¡Êý
ʹÓÃMath.round Ôõô¶¼Ëã²»¶Ô,½á¹û¶¼ÊÇ555.55 ,òËÆÊÇÒòΪjava¼ÆË㸡µãÊýʱ»áĪÃûÆäÃîÔÚ½áβ¸úÉÏÒ»´®Êý×Ö ±ÈÈç555.55500000003
ÎÞÄÎÖ»ÄÜдÕâ¸ö·½·¨
function round(a,b){
var s=a.toString().indexOf(".");
a0=a.toString().substr(0,s+b+1);
a1=Math.round(a.toString().sub ......
ÀàµÄ¶¨ÒåÓÐ3ÖÖ»ù±¾·½·¨:
1¡¢´´½¨²¢ÄÜ·µ»ØÌض¨ÀàÐ͵ĶÔÏóµÄº¯Êý(¹¤³§º¯Êý)È磺
function wu()
{
var w=new object;
o.a=1;
return o;
}ÓÃÕâÖÖ·½Ê½´´½¨¶ÔÏó£ºvar u=wu();
2¡¢´´½¨¹¹Ô캯Êý£¬ÓÃnewʵÀý»¯ÀýÈ磺
function wu()
{this.a=1;}
ÓÃÕâÖÖ·½Ê½´´½¨¶ÔÏó: var u=new wu();
3¡¢ÔÐÍ·½Ê½,À ......