posts - 5,  comments - 5,  trackbacks - 0

          網(wǎng)頁(yè)經(jīng)典代碼
          1. 將徹底屏蔽鼠標(biāo)右鍵,無(wú)右鍵菜單
          <body oncontextmenu=window.event.returnvalue=false>

          也可以用于網(wǎng)頁(yè)中Table框架中
          <table border oncontextmenu=return(false)><td>no</table>


          2.取消選取、防止復(fù)制
          <body onselectstart=return false>


          3.不準(zhǔn)粘貼
          <body onpaste=return false>


          4.防止復(fù)制
          <body oncopy=return false; oncut=return false;>


          5.IE地址欄前換成自己的圖標(biāo)
          <link rel=Shortcut Icon href=favicon.ico>

          說(shuō)明:關(guān)于favicon.ico文件的制作。你可以先在FW中做一個(gè)圖片,屬于你自己站點(diǎn)一個(gè)小圖標(biāo)。然后在ACD see將文件屬性改為*.ico,然后將你做的*.ICO文件傳到你的服務(wù)器目錄中,然后就可以使用以上代碼來(lái)實(shí)現(xiàn),當(dāng)別人登陸你的站點(diǎn)時(shí),地址欄里使用的就是你自定義的圖標(biāo)了。


          6.可以在收藏夾中顯示出你的圖標(biāo)
          <link rel=Bookmark href=favicon.ico>

          說(shuō)明:制作方法和上面的一樣。只是顯示的方式不同,這個(gè)是在別人收藏你的網(wǎng)頁(yè)地址時(shí)顯示的個(gè)性圖標(biāo)。


          7.關(guān)閉輸入法
          <input style=ime-mode:disabled>

          說(shuō)明:這段代碼是在表格提交時(shí)用到的。也就是在輸入數(shù)據(jù)時(shí)不可以使用其他輸入法模式。


          8.永遠(yuǎn)都會(huì)帶著框架
          <script language=javascript><!--
           if (window == top)top.location.href = frames.htm;// --></script>

          說(shuō)明:frames.htm為你的網(wǎng)頁(yè),這也是保護(hù)頁(yè)面的一種方法


          9.防止被人frame
          <SCRIPT LANGUAGE=javascript><!--
           if (top.location != self.location)top.location=self.location;
          // --></SCRIPT>


          10.網(wǎng)頁(yè)將不能被另存為
          <noscript><iframe src=*.html></iframe></noscript>
          說(shuō)明:<noscirpt>的用法很廣,其中一條就是可以使JS廣告失效。


          11.查源文件
          <input type=button value=查看網(wǎng)頁(yè)源代碼
          onclick=window.location = 'view-source:'+ target=_blank>[url]http://bbs.055.cn/test.htm[/url]';>


          12.COOKIE腳本記錄,有很大的用處哦

          function get_cookie(Name) {
          var search = Name + =

          var returnvalue = ;

          if (documents.cookie.length > 0) {

          offset = documents.cookie.indexOf(search)

          if (offset != -1) { // if cookie exists

          offset += search.length

          // set index of beginning of value

          end = documents.cookie.indexOf(;, offset);

          // set index of end of cookie value

          if (end == -1)

          end = documents.cookie.length;

          returnvalue=unescape(documents.cookie.substring(offset, end))

          }

          }

          return returnvalue;

          }


          function loadpopup(){

          if (get_cookie('popped')==''){

          openpopup()

          documents.cookie=popped=yes

          }

          }

          說(shuō)明:以上是JS代碼,請(qǐng)自己加起始符和結(jié)束符


          13.內(nèi)框架<IFRAME>使用
          Iframe標(biāo)記的使用格式是:   

          <iframe src=URL width=x height=x scrolling=[OPTION] frameborder=x
          name=main></iframe>
          src:文件的路徑,既可是HTML文件,也可以是文本、ASP等  
          width、height:內(nèi)部框架區(qū)域的寬與高;   
          scrolling:當(dāng)SRC的指定的HTML文件在指定的區(qū)域不顯不完時(shí),滾動(dòng)選項(xiàng),如果設(shè)置為NO,則不出現(xiàn)滾動(dòng)條;如為Auto:則自動(dòng)出現(xiàn)滾動(dòng)條;如為Yes,則顯示;  FrameBorder:區(qū)域邊框的寬度,為了讓“內(nèi)部框架“與鄰近的內(nèi)容相融合,常設(shè)置為0。
          name:框架的名字,用來(lái)進(jìn)行識(shí)別。
          比如:  當(dāng)你想用父框架控制內(nèi)部框架時(shí),可以使用: target=框架的名字來(lái)控制。

          例子:<iframe name=mm src=http://bbs.055.cn;; width=100% height=100% marginwidth=0 marginheight= ... ot; frameborder=0 scrolling=no></iframe>

          14.自動(dòng)跳轉(zhuǎn)
          在源代碼中的<head>…</head>加入如下代碼:
          <meta http-equiv=refreshcontent=3;URL=http://bbs.055.cn; charset=gb2312>

          說(shuō)明:content=3 表示3秒刷新到URL


          15.如何改變鏈接的鼠標(biāo)形狀
          只需在鏈接上加上這一代碼就行的了
          或者跟上面的用CSS寫(xiě)也行

          style=cursor:hand       style=cursor:crosshair
          style=cursor:text       style=cursor:wait
          style=cursor:move       style=cursor:help
          style=cursor:e-resize     
          style=cursor:n-resize
          style=cursor:nw-resize     style=cursor:w-resize
          style=cursor:s-resize     
          style=cursor:se-resize
          style=cursor:sw-resize

          以上代碼你只需要加到連接或是頁(yè)面的style區(qū)里就可以實(shí)現(xiàn)鼠標(biāo)多樣化。


          16.全屏顯示
          <form>
          <div align=center>
          <input type=BUTTON name=FullScreen value=全屏顯示 onClick=window.open(document.location, 'big', 'fullscreen=yes')>
          </div>
          </form>

          把它放到<body>區(qū)中。


          17.設(shè)為首頁(yè)

          <script language=javascript>
          <!--
          function defaul_home(){
          this.home.style.behavior='url(#default#homepage)';this.home.setHomePage([url]http://bbs.055.cn/[/url]';
          }
          var focusok=false;
          if (navigator.appName == Netscape{
          focusok=true;
          }
          vers=navigator.appVersion;
          if (navigator.appName == Microsoft Internet Explorer{
          pos=vers.lastIndexOf('.');
          vers=vers.substring(pos-1,vers.length);
          }
          proper_version=parseFloat(vers);

          if(proper_version>=5){
          focusok=true;
          }
          function launchstock1(htmlurl){
          var stock=window.open(htmlurl,stock,top=2,left=2,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,
          resizable=no,width=700,height=510;
          if(focusok){
          stock.focus();
          }
          return true;
          }
          function launchstock(){
          var stock=window.open(,stock,top=2,left=2,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,

          resizable=no,width=700,height=510;
          if(focusok){
          stock.focus();
          }
          return true;
          }
          // -->
          </script>
          <a href=# name=home onClick=defaul_home(); title===E代時(shí)光==>設(shè)為首頁(yè)</a>


          18.這里是加入收藏夾的代碼

          <a href=# onClick=window.external.addFavorite([url]http://bbs.055.cn[/url]';.'拂曉雅閣') target=_self title=拂曉雅閣>加入收藏夾</a>


          19.flash圖片效果
          以下代碼加入<head>區(qū)域
          <SCRIPT language=javascript>
          <!--
          function makevisible(cur,which){
          if (which==0)
          cur.filters.alpha.opacity=100
          else
          cur.filters.alpha.opacity=20
          }

          //-->

          </SCRIPT>
          以下代碼加入<body>區(qū)域
          <img src=http://bbs.055.cn/images/logo.gif;; style=filte ... nbsp;onMouseOver=makevisible(this,0) onMouseOut=makevisible(this,1) width=63 height=56> //圖片地址請(qǐng)自己改


          20.load 進(jìn)度條

          <table cellspacing=0 cellpadding=0 bgcolor=#FFFFFF width=40% id=P><tr><td>
          <table cellspacing=0 cellpadding=0 bgcolor=#0000FF height=18 id=Q><tr><td></td></tr></table></td></tr></table>
          </center>
          <script language=javascript>
          var R = 0; load();
          function load() {R = R + 2; Q.style.width = R + %; time= setTimeout(load(),50);
          if (R > 100) {clearTimeout(time); P.style.width=0}}
          </script>
          27 全屏
          <script language=javascript>
          window.open('index.asp','','fullscreen=1');
          </script>


          21.背景圖片滾動(dòng)

          <body scroll=no background=images/bg.jpg link=#00FF00 alink=#FF0000 vlink=#00FF00 bgcolor=#000080 topmargin=8>
          <script language=javascript>
          var backgroundOffset = 0;
          var bgObject = eval('document.body');
          function scrollBG(maxSize) {backgroundOffset = backgroundOffset + 1;
          if (backgroundOffset > maxSize) backgroundOffset = 0;
          bgObject.style.backgroundPosition = 0? + backgroundOffset;}
          var ScrollTimer = window.setInterval(scrollBG(410), 20)
          </script>


          22.網(wǎng)頁(yè)不會(huì)被緩存

          HTMl網(wǎng)頁(yè)
          <META HTTP-EQUIV=pragma CONTENT=no-cache>
          <META HTTP-EQUIV=Cache-Control CONTENT=no-cache, must-revalidate>
          <META HTTP-EQUIV=expires CONTENT=Wed, 26 Feb 1997 08:21:57 GMT>
          或者<META HTTP-EQUIV=expires CONTENT=0>
          ASP網(wǎng)頁(yè)
           Response.Expires = -1
           Response.ExpiresAbsolute = Now() - 1
           Response.cachecontrol = no-cache
          PHP網(wǎng)頁(yè)
          header(Expires: Mon, 26 Jul 1997 05:00:00 GMT;
          header(Cache-Control: no-cache, must-revalidate;
          header(Pragma: no-cache;


          23.

          <%
          '定義數(shù)據(jù)庫(kù)連接的一些常量
          Const adOpenForwardOnly   = 0 '游標(biāo)只向前瀏覽記錄,不支持分頁(yè)、Recordset、BookMark
          Const adOpenKeyset     = 1 '鍵集游標(biāo),其他用戶(hù)對(duì)記錄說(shuō)做的修改將反映到記錄集中,但其他用戶(hù)增加或刪除記錄不會(huì)反映到記錄集中。支持分頁(yè)、Recordset、BookMark
          Const adOpenDynamic     = 2 '動(dòng)態(tài)游標(biāo)功能最強(qiáng),但耗資源也最多。用戶(hù)對(duì)記錄說(shuō)做的修改,增加或刪除記錄都將反映到記錄集中。支持全功能瀏覽(ACCESS不支持)。
          Const adOpenStatic     = 3 '靜態(tài)游標(biāo),只是數(shù)據(jù)的一個(gè)快照,用戶(hù)對(duì)記錄說(shuō)做的修改,增加或刪除記錄都不會(huì)反映到記錄集中。支持向前或向后移動(dòng)
          Const adLockReadOnly    = 1 '鎖定類(lèi)型,默認(rèn)的,只讀,不能作任何修改
          Const adLockPessimistic   = 2 '當(dāng)編輯時(shí)立即鎖定記錄,最安全的方式
          Const adLockOptimistic   = 3 '只有在調(diào)用Update方法時(shí)才鎖定記錄集,而在此前的其他操作仍可對(duì)當(dāng)前記錄進(jìn)行更改、插入和刪除等
          Const adLockBatchOptimistic = 4 '當(dāng)編輯時(shí)記錄不會(huì)被鎖定,而更改、插入和刪除是在批處理方式下完成的
          Const adCmdText = &H0001
          Const adCmdTable = &H0002
          %>


          24.最小化、最大化、關(guān)閉窗口
          <object id=hh1 classid=clsidDB880A6-D8FF-11CF-9377-00AA003B7A11>
          <param name=Command value=Minimize></object>
          <object id=hh2 classid=clsidDB880A6-D8FF-11CF-9377-00AA003B7A11>
          <param name=Command value=Maximize></object>
          <OBJECT id=hh3 classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11>
          <PARAM NAME=Command value=Close></OBJECT>
          <input type=button value=最小化 onclick=hh1.Click()>
          <input type=button value=最大化 onclick=hh2.Click()>
          <input type=button value=關(guān)閉 onclick=hh3.Click()>

          說(shuō)明:本例適用于IE


          25.判斷上一頁(yè)的來(lái)源

          asp頁(yè):
          request.servervariables(HTTP_REFERER
          java script:
          document.referrer


          26.光標(biāo)是停在文本框文字的最后

          <script language=javascript>
          function cc()
          {
           var e = event.srcElement;
           var r =e.createTextRange();
           r.moveStart('character',e.value.length);
           r.collapse(true);
           r.select();
          }
          </script>
          <input type=text name=text1 value=123 onfocus=cc()>

          說(shuō)明:適用于表格數(shù)據(jù)提交

          ?

          posted on 2006-12-25 16:13 曾科 閱讀(191) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): JavaScript
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(3)

          隨筆檔案

          文章分類(lèi)

          文章檔案

          相冊(cè)

          .net

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 巫溪县| 赤城县| 公主岭市| 永昌县| 商洛市| 义马市| 灌阳县| 屏东市| 家居| 新民市| 嘉善县| 鄂托克前旗| 嘉黎县| 镇康县| 家居| 紫阳县| 织金县| 九江市| 长海县| 贡嘎县| 城口县| 望奎县| 昭苏县| 宜州市| 怀宁县| 元谋县| 洮南市| 彭州市| 泰来县| 青河县| 阿拉善左旗| 普安县| SHOW| 惠州市| 施秉县| 科技| 鄂托克前旗| 安丘市| 濮阳市| 金寨县| 巴东县|