幾個有趣的Javascript Hack_javascript技巧

來源:互聯網
上載者:User
1. 直接在瀏覽器中編輯網頁內容
複製代碼 代碼如下:
javascript:document.body.contentEditable='true';document.designMode='on'; void(0);
訪問任意網站,在地址欄輸入以上代碼,會發生當前網頁已經變成編輯模式了。

2. 舞動的圖片
複製代碼 代碼如下:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);


3、晃來晃去(我這邊測試不可以)
不但是你,瀏覽器也不是那麼喜歡這個javascript。在地址欄運行這個代碼後,瀏覽器會迅速地晃來晃去。代碼如下:
複製代碼 代碼如下:

javascript:function flood(n) {if (self.moveBy) {for (i = 200; i > 0;i--){for (j = n; j > 0; j--) {self.moveBy(1,i); self.moveBy(i,0);self.moveBy(0,-i); self.moveBy(-i,0); } } }}flood(6);{ var inp = "D-X !msagro na dah tsuj resworb rouY"; var outp = ""; for (i = 0; i <= inp.length; i++) {outp =inp.charAt (i) + outp ; } alert(outp) ;}; reverse

如果這個代碼無效,請將">"改成">","&It;'改成"<"。
4、計算機
在地址欄輸入下面的代碼,可以實現簡單的四則運算:
複製代碼 代碼如下:

javascript: alert(34343+3434-222);

事實上這個代碼可以繼續簡化,比如簡化成這樣:
javascript: 34343+3434-222
5、防網路釣魚驗證
某些釣魚網站提供的URL和網頁本身的URL是不一致的,你可以用下面的代碼進行驗證,當兩個URL相差太大的時候,你就要稍加小心了:
javascript:alert("The actual URL is:tt" + location.protocol + "//" + location.hostname + "/" + "nThe address URL is:tt" + location.href + "n" + "nIf the server names do not match, this may be a spoof.");

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.