js ·

神奇的代码——JavaScript在浏览器中的妙用

经常使用IE的朋友,可能喜欢在地址栏中输入一些Javascript代码来实现一些特定的功能。比如,测试一段Javascript代码是否正确,放大网页,提取网页中的所有图片,等等。

        现精心从网上淘了一些有价值的JavaScript代码,有兴趣的可以试试。方法:将给出的代码复制到浏览器地址栏(如果你够笨,那你就对照着一个字符一个字符的敲吧,我晕~~)然后回车就行了。

        1.在任意网站上随意涂鸦

        javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

        这是一段神奇的代码,利用此代码黑掉Google、Baidu……简直就是举手之劳啊!只要你在IE浏览器任意打开一个网站,然后在浏览器上输入前面这段代码然后回车,你就可以随心所欲的修改这个网站啦!想想google的页面被自己改得面目全非,是不是过足了黑客瘾啊!

        输入如下代码,将退出编辑状态:javascript:document.body.contentEditable='false'; 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; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);

        3.解除右健锁定

        javascript:function document.oncontextmenu(){return true;} function document.onselectstart(){return true;} function document.onsdragstart(){return true;}

        4.显示网页中的所有图片

        javascript:Ai7Mg6P='';for%20(i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){Ai7Mg6P+='<img%20src='+document.images[i7M1bQz].src+'><br>'};if(Ai7Mg6P!=''){document.write('<center>'+Ai7Mg6P+'</center>');void(document.close())}else{alert('No%20images!')}

        5.显示网页中除图片的其他

        javascript:for(jK6bvW=0;jK6bvW<document.images.length;jK6bvW++){void(document.images[jK6bvW].style.visibility='hidden')}

        6.显示网页源代码(对于加密过的可以直接显示其加密前的源代码)

        javascript:s=document.documentElement.outerHTML;document.write('<body></body>');document.body.innerText=s;

        7.网页放大1.5倍

        javascript:void(s=document.body.style);void(z=s.getAttribute('zoom'));if(z){s.setAttribute('zoom',(parseInt(z)+50)+'%');}else s.setAttribute('zoom','150%')

        8.网页缩小0.5倍

        javascript:void(s=document.body.style);void(z=s.getAttribute('zoom'));if(z){s.setAttribute('zoom',(parseInt(z)-50)+'%');}else s.setAttribute('zoom','50%')

        9.把隐藏的表单显示出来

        javascript:for(i=0;i<document.all.length;i++){document.body.all[i].maxLength=2147483647;document.body.all[i].outerHTML =document.body.all[i].outerHTML.replace(/type=(radio)|(hidden)|(checkbox)/i,'type=text');}void 0

参与评论