隨筆 - 0, 文章 - 75, 評論 - 0, 引用 - 0
          數(shù)據(jù)加載中……

          補充JS中的特效(常更新)

          設置文本框不允許有焦點:


          <input type="text" disabled="disabled">



          設置confirm()中的文本內容:


          confirm("您本次購買的商品信息如下:\n商品名稱:跑跑游戲道具;\n商品數(shù)量:5件;\n商品單價:12.5");


          \n即代表換行



          設置全屏漂浮廣告:


          <script language="javascript">


          var x = 50,y = 60; //浮動廣告初始位置


          var xin = true, yin = true; //xin為真,則向右運動,否則向左運動;


          //yin為真,則向下運動,否則向上運動


          var step = 1; //移動的距離


          var delay = 10; //移動的事件間隔


          function floatAD(){


          var L=T=0; //L左邊界,T上邊界


          var R =
          document.body.offsetHeight-document.getElementByIdx_x_x("fly").offsetWidth;
          //層移動的右邊界


          var B = document.body.offsetHeight-document.getElementByIdx_x_x("fly").offsetHeight; //層移動的下邊界


          document.getElementByIdx_x_x("fly").style.left = x ; //層移動后的左邊界


          document.getElementByIdx_x_x("fly").style.top = y ;
          //層移動后的上邊界


          x = x + step * (xin ? 1 :
          -1); //判斷水平方向


          if(x < L){xin = true; x =
          L;} //到達邊界后的處理


          if(x > R){xin = false; x = R;}


          y = y + step * (yin ? 1 : -1);


          if(y < T){yin = true; y =
          T;}


          if(y > B){yin = false; y = B;}


          setTimeout("floatAD()",delay) //隔多久調用一次


          }


          </script>



          如何利用JS:


          oncontextmenu="window.event.returnValue=false"
          將徹底屏蔽鼠標右鍵


          <body onselectstart="return
          false">
          取消選取、防止復制
          onpaste="return
          false"
          不準粘貼
          oncopy="return false;" oncut="return
          false;"
          防止復制


          -----------------------------------


          1.右鍵無效
          view plaincopy to
          clipboardprint
          <script>
          document.oncontextmenu=new
          Function("event.returnValue=false;");
          </script>
          <body>
          右鍵無效
          </body>


          2.禁止網(wǎng)頁復制
          view plaincopy to clipboardprint?
          <body>

          <script
          type="text/javascript">
          document.body.oncopy=nocopy;
          function
          nocopy(){
          clipboarData.setData("text","");
          setTimeout(nocopydelay,100);
          }


          function
          nocopydelay(){
          alert("不能復制");
          clipboarData.setData("text","哈哈"+"\r\n文章來自:sxzlc詳細參考:"+location.href);
          }

          </script>


          無法復制,但是internet選項安全腳本活動腳本禁用后就可以復制了。<br>

          需要使用一下延時。
          script要在body內部,否則不好使。

          強烈建議沒有什么特殊要求別在自己的網(wǎng)頁上這么弄。
          </body>
          3.禁止F5刷新
          view plaincopy to
          clipboardprint?
          <script
          type="text/javascript">
          document.onkeydown=function()//禁止刷新
          {
          if(event.keyCode==116){
          event.keyCode=0;
          event.returnValue=false;
          }
          }


          document.oncontextmenu=function(){
          event.returnValue=false;
          }
          </script>


          4.js中的alert的意外發(fā)現(xiàn),以前不知道。
          view plaincopy to clipboardprint?
          <script
          type="text/javascript">
          function
          sss()
          {
          alert(sss);
          alert('sss');
          }
          </script>
          <body
          onload=sss();>
          運行一下,非常有意思。
          第一個,會把函數(shù)的內容顯示出來,對話框的內容是:function
          sss(){....}
          第二個輸出才是sss
          </body>


          5.屏蔽js錯誤
          <script language="javascript">
          <!--

          function
          killerrors() {
          return true;
          }
          window.onerror =
          killerrors;
          //-->
          </script>
          <mec:script
          language="javascript">
          function
          sss(){
          alert(sss);
          alert('sss');
          alert(aaaaa);
          }
          </script>
          <body
          onload=sss();>
          代碼中注釋去掉與否沒有影響!
          </body>


          6.禁用backspace退格鍵
          function
          document.onkeydown(){
          if(event.keyCode==8){
          if(document.activeElement.type=="text"){
          if(document.activeElement.readOnly==false)
          return
          true;


          }
          return false;
          }
          }

          posted on 2012-04-22 15:16 hantai 閱讀(141) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 海丰县| 九龙坡区| 贺兰县| 静安区| 府谷县| 驻马店市| 龙山县| 昭苏县| 三河市| 唐河县| 贡嘎县| 巴塘县| 射洪县| 德庆县| 保康县| 泰宁县| 全椒县| 衡水市| 遵义市| 余干县| 依安县| 罗甸县| 赣榆县| 陇川县| 垣曲县| 邵东县| 荃湾区| 阳山县| 高陵县| 卢湾区| 光山县| 夏河县| 许昌市| 改则县| 山西省| 太仓市| 泗洪县| 正镶白旗| 德庆县| 嘉禾县| 莆田市|