日期:2014-05-16  浏览次数:20630 次

js趣味代码

写了个chrome的插件实现自动填写表单的,用的是js,然后在网上搜索了一些,整理了一些js的趣味代码,如下:


把这个粘贴到ff或chrome的地址栏中,找一个有图的网址:




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);




IE下:
javascript:R=0;%20x1=.1;%20y1=.05;%20x2=.25;%20y2=.24;%20x3=1.6;%20y3=.24;%20x4=300;%20y4=200;%20x5=300;%20y5=200;%20DI=document.images;%20DIL=DI.length;%20function%20A(){for(i=0;%20i-DIL;%20i++){DIS=DI[%20i%20].style;%20DIS.position='absolute';%20DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;%20DIS.top=Ma




JavaScript除了直接嵌入到HTML或通过js文件调用执行外,还可以在IE、火狐等浏览器的地址栏里直接输入代码后按回车键来执行,即使不懂js代码,也可通过对js代码复制粘贴的操作轻松实现相应的网页功能效果。下面是从abcd数据库转载的一些实用的js代码:




解除网页不允许复制的设置
javascript :document.oncontextmenu="return true";document.onselectstart="return true";document.body.onselectstart="return true";document.body.onselect="return true";document.body.oncopy="return true";document.body.onbeforecopy="return true";document.body.oncontextmenu="return true";document.body.onmouseup="return true";void 0; 




将网页转换为编辑模式
javascript :document.body.contentEditable='true'; document.designMode='on'; void(0);




显示网页源代码
javascript :s=document.documentElement.outerHTML;document.body.innerText="<textarea rows=30  cols=90>"+s+"</textarea>";




只显示网页中的图片
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!')}




只显示网页中的文字
javascript :for(jK6bvW=0;jK6bvW<document.images.length;jK6bvW++){void(document.images[jK6bvW].style.visibility='hidden')}




计算器
javascript : alert(123+456*789-54321);




以明文方式显示网页密码框中的密文
javascript :(function(){var s,F,j,f,i;s="";F=document.forms;for(j=0;j<F.length;++j){f=F[j];for(i=0;i<f.length;++i){if(f[i].type.toLowerCase()=="password")s+=f[i].value+"\n";}}if(s)在地址栏输入下面的代码按enter,网页上所有元素都能变成可编辑状态,你可以移动、调整元素大小。如果你只是讨厌某个网站想发泄一下,我建议你使用NetDisater。




代码如下:




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




这是经重新编辑的google.cn:alert("Passwords in forms on this page:\n\n"+s);else alert("There are no passwords in forms on this page.");})(); 




晃来晃去




不但是你,浏览器也不是那么喜欢这个javascript。在地址栏运行这个代码后,浏览器会迅速地晃来晃去。代码如下:




javascript:function flood(n) {if (self.moveBy) {for (i = 200; i &gt; 0;i--){for (j = n; j &gt; 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 &lt;= inp.length; i++) {outp =inp.charAt (i) + outp ; } alert(outp) ;}; reverse




如果这个代码无效,请将"&gt;"改成">","&It;'改成"<"。






防钓鱼验证




某些钓鱼网站提供的URL和网页本身的URL是不一致的,你可以用下面的代码进行验证,当两个URL相差太大的时候,你就要稍加小心了:




javascript:alert("The actual URL is:tt" + loca