使用JavaScript完成最简单加密解密和模仿QQ的窗口抖动效果
2012-03-21 19:28
447 查看
众所周知,在计算机里面,字符串都需要编码,在非英文字符都需要一个专门的编码方式,我们可以利用这种方式来
做一个简单的加密解密小程序。
这里使用JavaScript里面自带的escape函数,这个函数接受一个字符串,然后返回百分号加上Unicode字符集的编
码,然后unescape函数正好相反,就是接受这些乱码,然后翻译成中文。
代码如下
然后介绍重头戏,模仿窗口抖动特效,直接上代码
大家可以使用IE看效果,貌似只有IE能看效果。JavaScript某些函数还是兼容性有问题
做一个简单的加密解密小程序。
这里使用JavaScript里面自带的escape函数,这个函数接受一个字符串,然后返回百分号加上Unicode字符集的编
码,然后unescape函数正好相反,就是接受这些乱码,然后翻译成中文。
代码如下
<!DOCTYPE html> <html> <head> <title>最简单的加密与解密</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function $(str){ return (document.getElementById(str)); } </script> </head> <body> 请输入需要加密和解密的内容<br/> <textarea rows="10" cols="50" id="txt1"></textarea><br/> <input type="button" value="加密" onclick="$('txt2').value=escape($('txt1').value);"> <input type="button" value="解密" onclick="$('txt2').value=unescape($('txt1').value);"> 结果输出<br/> <textarea rows="10" cols="50" id="txt2"></textarea> </body> </html>
然后介绍重头戏,模仿窗口抖动特效,直接上代码
<!DOCTYPE html> <html> <head> <title>模拟震动闪屏效果</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function resizeWindow(){ var windowWidth=240, windowHeight=180; window.moveTo((screen.availWidth-windowWidth)/2, (screen.availHeight-windowHeight)/2); window.resizeTo(windowWidth, windowHeight); } function shakeWin(stepId){ var stepId; if(!stepId) stepId=0; switch (stepId) { case 0: window.moveBy(-5, -5); break; case 1: window.moveBy(10, 0); break; case 2: window.moveBy(-10, 10); break; case 3: window.moveBy(10, 0); break; case 4: window.moveBy(-5, -5); break; default: break; } stepId++; setTimeout("shakeWin("+stepId+")", 20); } window.onload=resizeWindow(); </script> </head> <body> <input type="button" value="点击查看闪屏效果" onclick="shakeWin();"> </body> </html>
大家可以使用IE看效果,貌似只有IE能看效果。JavaScript某些函数还是兼容性有问题
相关文章推荐
- 使用JavaScript完成最简单加密解密和模仿QQ的窗口抖动效果
- 用javascript DOM模仿QQ窗口抖动效果(超级简单哦~~·)
- 使用RSA非对称加密完成JavaScript前端分段加密和java后端分段解密
- UI基础第十四弹:使用UItableview完成一个简单的QQ好友列表(一)
- 使用UItableview完成一个简单的QQ好友列表(二)
- 网页用 JavaScript DOM 仿作QQ的窗口抖动效果,超简单~~~
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- javascript(js)使用eval方法加密过的函数解密方法
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(二)
- 使用kettle转换中的JavaScript对密码进行加密和解密
- 教你一天玩转JavaScript(七)——使用JavaScript完成复选框的全选和全不选的效果
- 请写一个简单的幻灯效果页面,不使用JS来完成怎么做
- RSA使用javascript加密JAVA解密
- javascript增加干扰数据实现简单加密效果
- 使用python实现简单的加密解密机制
- Java简单的加密解密算法,使用异或运算
- c#如何使用webservice、存储过程及存储过程的创建(简单模仿类似QQ统计用户在线时间为例)
- C++实现文件简单加密与解密(读取文件中的字符,对字符转换,然后写入,完成加密,解密反之)
- 超简单的使用drawerlayout实现QQ的侧拉面板效果
- 使用AES算法完成对数据的加密和解密