網頁常用的美化-JavaScript

來源:互聯網
上載者:User
  1. 網頁常用Javascript 
  2. 1.讓文字不停地滾動 
  3.   <MARQUEE>滾動文字</MARQUEE> 
  4. 2.記錄並顯示網頁的最後修改時間 
  5.   <script language=Javascript> 
  6.   document.write("最後更新時間: " + document.lastModified + "") 
  7.   </script> 
  8. 3.關閉當前視窗 
  9.   <a href="/"onClick="javascript:window.close();return false;">關閉視窗</a> 
  10. 4.5秒後關閉當前頁 
  11.   <script language="Javascript"> 
  12.   <!-- 
  13.   setTimeout('window.close();',5000); 
  14.   --> 
  15.   </script> 
  16. 5.2秒後載入指定網頁 
  17.   <head> 
  18.   <meta http-equiv="refresh" content="2;URL=http://你的網址"> 
  19.   </head> 
  20. 6.添加到收藏夾 
  21.   <script Language="Javascript"> 
  22.   function bookmarkit() 
  23.   { 
  24.   window.external.addFavorite('http://你的網址','你的網站名稱') 
  25.   } 
  26.   if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夾</a>') 
  27.   </script> 
  28. 7.讓超連結不顯示底線 
  29.   <style type="text/css"> 
  30.   <!- 
  31.   a:link{text-decoration:none} 
  32.   a:hover{text-decoration:none} 
  33.   a:visited{text-decoration:none} 
  34.   -> 
  35.   </style> 
  36. 8.禁止滑鼠右鍵的動作 
  37.   <script Language = "Javascript"> 
  38.   function click() { if (event.button==2||event.button==3) 
  39.   { 
  40.   alert('禁止滑鼠右鍵'); 
  41.   } 
  42.   document.onmousedown=click // --> 
  43.   </script> 
  44. 9.設定該頁為首頁 
  45.   <body bgcolor="#FFFFFF" text="#000000"> 
  46.   <!-- 網址:http://你的網址--> 
  47.   <a class="chlnk" style="cursor:hand" HREF 
  48.   onClick="this.style.behavior='url(#default#homepage)'; 
  49.   this.setHomePage('你的網站名稱);"><font color="000000" size="2" face="宋體">設為首頁</font></a> 
  50.   </body> 
  51. 10.節日倒計時 
  52.   <script Language="Javascript"> 
  53.   var timedate= new Date("December 25,2003"); 
  54.   var times="聖誕節"; 
  55.   var now = new Date(); 
  56.   var date = timedate.getTime() - now.getTime(); 
  57.   var time = Math.floor(date / (1000 * 60 * 60 * 24)); 
  58.   if (time >= 0) 
  59.   document.write("現在離"+times+"還有: "+time +"天")</script> 
  60. 11.單擊按鈕列印出當前頁 
  61.   <script Language="Javascript"> 
  62.   <!-- Begin 
  63.   if (window.print) { 
  64.   document.write('<form>' 
  65.   + '<input type=button name=print value="列印本頁" ' 
  66.   + 'onClick="javascript:window.print()"></form>'); 
  67.   } 
  68.   // End --> 
  69.   </script> 
  70. 12.單擊按鈕‘另存新檔’當前頁 
  71.   <input type="button" name="Button" value="儲存本頁" 
  72.   onClick="document.all.button.ExecWB(4,1)"> 
  73.   <object id="button" 
  74.   width=0 
  75.   height=0 
  76.   classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> 
  77.   <embed width="0" height="0"></embed> 
  78.   </object> 
  79. 13.顯示系統當前日期 
  80.   <script language=Javascript> 
  81.   today=new Date(); 
  82.   function date(){ 
  83.   this.length=date.arguments.length 
  84.   for(var i=0;i<this.length;i++) 
  85.   this[i+1]=date.arguments } 
  86.   var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); 
  87.   document.write( 
  88.   "<font color=##000000 style='font-size:9pt;font-family: 宋體'> ", 
  89.   today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日", 
  90.   d[today.getDay()+1],"</font>" ); 
  91.   </script> 
  92. 14.不同時間段顯示不同問候語 
  93.   <script Language="Javascript"> 
  94.   <!-- 
  95.   var text=""; day = new Date( ); time = day.getHours( ); 
  96.   if (( time>=0) && (time < 7 )) 
  97.     text="夜貓子,要注意身體哦! " 
  98.   if (( time >= 7 ) && (time < 12)) 
  99.     text="今天天氣……哈哈哈,不去玩嗎?" 
  100.   if (( time >= 12) && (time < 14)) 
  101.     text="午休時間哦,朋友一定是不習慣午睡的吧?!" 
  102.   if (( time >=14) && (time < 18)) 
  103.     text="下午茶的時間到了,休息一下吧! " 
  104.   if ((time >= 18) && (time <= 22)) 
  105.     text="您又來了,可別和MM聊太久哦!" 
  106.   if ((time >= 22) && (time < 24)) 
  107.     text="很晚了哦,注意休息呀!" 
  108.   document.write(text) 
  109.   //---> 
  110.   </script> 
  111. 15.水中倒影效果 
  112.   <img id="reflect" src="你自己的圖片檔案名稱" width="175" height="59"> 
  113.   <script language="Javascript"> 
  114.   function f1() 
  115.   { 
  116.     setInterval("mdiv.filters.wave.phase+=10",100); 
  117.   } 
  118.   if (document.all) 
  119.   { 
  120.     document.write('<img id=mdiv src="'+document.all.reflect.src+'" 
  121.     style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">') 
  122.     window.onload=f1 
  123.   } 
  124.   </script> 
  125. 16.慢慢變大的視窗 
  126.   <script Language="Javascript"> 
  127.   <!-- 
  128.   var Windowsheight=100 
  129.   var Windowswidth=100 
  130.   var numx=5 
  131.   function openwindow(thelocation){ 
  132.   temploc=thelocation 
  133.   if 
  134.   (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)) 
  135.   { 
  136.     window.open(thelocation) 
  137.     return 
  138.   } 
  139.   windowsize=window.open("","","scrollbars") 
  140.   windowsize.moveTo(0,0) 
  141.   windowsize.resizeTo(100,100) 
  142.   tenumxt() 
  143.   } 
  144.   function tenumxt(){ 
  145.   if (Windowsheight>=screen.availHeight-3) 
  146.     numx=0 
  147.   windowsize.resizeBy(5,numx) 
  148.   Windowsheight+=5 
  149.   Windowswidth+=5 
  150.   if (Windowswidth>=screen.width-5) 
  151.   { 
  152.     windowsize.location=temploc 
  153.     Windowsheight=100 
  154.     Windowswidth=100 
  155.     numx=5 
  156.     return 
  157.   } 
  158.   setTimeout("tenumxt()",50) 
  159.   } 
  160.   //--> 
  161.   </script> 
  162.   <p><a href="javascript:openwindow(http://www.3ydesign.com)">進入</a> 
  163. 17.改變IE地址欄的IE表徵圖 
  164.   我們要先做一個16*16的icon(表徵圖檔案),儲存為index.ico。把這個表徵圖檔案上傳到根目錄下並在首頁<head></head>之間加上如下代碼: 
  165.   <link REL = "Shortcut Icon" href="index.ico">  
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.