js仿黑客帝国字母掉落效果代码分享

看过黑客帝国的朋友或许都对开头的字幕效果很熟悉,自从影片播放以来,网页设计者有不少都在模仿这种字母掉落的效果,而且最后还有文字显现效果“I love you”,你可以稍加修改,在情人节,用来对你的恋人表白哦~

运行效果图:

大家也动手运行一下,                                      ----------------效果演示----------------

为大家分享js仿黑客帝国字母掉落效果代码如下

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JS仿黑客帝国字母掉落效果</title>
<style type=text/css>
.matrix{padding-right: 0px; padding-left: 0px; font-size: 10pt; padding-bottom: 0px; margin: 0px; width: 10px; padding-top: 0px; font-family: lucida console, courier, monotype; text-align: center}
</style>
</head>
<body>
<center>JS仿黑客帝国字母掉落效果</center><br><center>

<SCRIPT language=JavaScript type=text/javascript>
var rows=11; // must be an odd number
var speed=50; // lower is faster
var reveal=2; // between 0 and 2 only. The higher, the faster the word appears
var effectalign="default" //enter "center" to center it.
var w3c=document.getElementById && !window.opera;;
var ie45=document.all && !window.opera;
var ma_tab, matemp, ma_bod, ma_row, x, y, columns, ma_txt, ma_cho;
var m_coch=new Array();
var m_copo=new Array();
window.onload=function() {
 if (!w3c && !ie45) return
 var matrix=(w3c)?document.getElementById("matrix"):document.all["matrix"];
 ma_txt=(w3c)?matrix.firstChild.nodeValue:matrix.innerHTML;
 ma_txt=" "+ma_txt+" ";
 columns=ma_txt.length;
 if (w3c) {
 while (matrix.childNodes.length) matrix.removeChild(matrix.childNodes[0]);
 ma_tab=document.createElement("table");
 ma_tab.setAttribute("border", 0);
 ma_tab.setAttribute("align", effectalign);
 ma_tab.style.backgroundColor="#000000";
 ma_bod=document.createElement("tbody");
 for (x=0; x<rows; x++) {
 ma_row=document.createElement("tr");
 for (y=0; y<columns; y++) {
 matemp=document.createElement("td");
 matemp.setAttribute("id", "Mx"+x+"y"+y);
 matemp.className="matrix";
 matemp.appendChild(document.createTextNode(String.fromCharCode(160)));
 ma_row.appendChild(matemp);
 }
 ma_bod.appendChild(ma_row);
 }
 ma_tab.appendChild(ma_bod);
 matrix.appendChild(ma_tab);
 } else {
 ma_tab='<ta'+'ble align="'+effectalign+'" border="0" style="background-color:#000000">';
 for (var x=0; x<rows; x++) {
 ma_tab+='<t'+'r>';
 for (var y=0; y<columns; y++) {
 ma_tab+='<t'+'d class="matrix" id="Mx'+x+'y'+y+'">?</'+'td>';
 }
 ma_tab+='</'+'tr>';
 }
 ma_tab+='</'+'table>';
 matrix.innerHTML=ma_tab;
 }
 ma_cho=ma_txt;
 for (x=0; x<columns; x++) {
 ma_cho+=String.fromCharCode(32+Math.floor(Math.random()*94));
 m_copo[x]=0;
 }
 ma_bod=setInterval("mytricks()", speed);
}

function mytricks() {
 x=0;
 for (y=0; y<columns; y++) {
 x=x+(m_copo[y]==100);
 ma_row=m_copo[y]%100;
 if (ma_row && m_copo[y]<100) {
 if (ma_row<rows+1) {
 if (w3c) {
 matemp=document.getElementById("Mx"+(ma_row-1)+"y"+y);
 matemp.firstChild.nodeValue=m_coch[y];
 }
 else {
 matemp=document.all["Mx"+(ma_row-1)+"y"+y];
 matemp.innerHTML=m_coch[y];
 }
 matemp.style.color="#33ff66";
 matemp.style.fontWeight="bold";
 }
 if (ma_row>1 && ma_row<rows+2) {
 matemp=(w3c)?document.getElementById("Mx"+(ma_row-2)+"y"+y):document.all["Mx"+(ma_row-2)+"y"+y];
 matemp.style.fontWeight="normal";
 matemp.style.color="#00ff00";
 }
 if (ma_row>2) {
 matemp=(w3c)?document.getElementById("Mx"+(ma_row-3)+"y"+y):document.all["Mx"+(ma_row-3)+"y"+y];
 matemp.style.color="#009900";
 }
 if (ma_row<Math.floor(rows/2)+1) m_copo[y]++;
 else if (ma_row==Math.floor(rows/2)+1 && m_coch[y]==ma_txt.charAt(y)) zoomer(y);
 else if (ma_row<rows+2) m_copo[y]++;
 else if (m_copo[y]<100) m_copo[y]=0;
 }
 else if (Math.random()>0.9 && m_copo[y]<100) {
 m_coch[y]=ma_cho.charAt(Math.floor(Math.random()*ma_cho.length));
 m_copo[y]++;
 }
 }
 if (x==columns) clearInterval(ma_bod);
}

function zoomer(ycol) {
 var mtmp, mtem, ytmp;
 if (m_copo[ycol]==Math.floor(rows/2)+1) {

 for (ytmp=0; ytmp<rows; ytmp++) {
 if (w3c) {
 mtmp=document.getElementById("Mx"+ytmp+"y"+ycol);
 mtmp.firstChild.nodeValue=m_coch[ycol];
 }
 else {
 mtmp=document.all["Mx"+ytmp+"y"+ycol];
 mtmp.innerHTML=m_coch[ycol];
 }
 mtmp.style.color="#33ff66";
 mtmp.style.fontWeight="bold";
 }
 if (Math.random()<reveal) {
 mtmp=ma_cho.indexOf(ma_txt.charAt(ycol));
 ma_cho=ma_cho.substring(0, mtmp)+ma_cho.substring(mtmp+1, ma_cho.length);
 }
 if (Math.random()<reveal-1) ma_cho=ma_cho.substring(0, ma_cho.length-1);
 m_copo[ycol]+=199;
 setTimeout("zoomer("+ycol+")", speed);
 }
 else if (m_copo[ycol]>200) {
 if (w3c) {
 mtmp=document.getElementById("Mx"+(m_copo[ycol]-201)+"y"+ycol);
 mtem=document.getElementById("Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol);
 }
 else {
 mtmp=document.all["Mx"+(m_copo[ycol]-201)+"y"+ycol];
 mtem=document.all["Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol];
 }
 mtmp.style.fontWeight="normal";
 mtem.style.fontWeight="normal";
 setTimeout("zoomer("+ycol+")", speed);
 }
 else if (m_copo[ycol]==200) m_copo[ycol]=100+Math.floor(rows/2);
 if (m_copo[ycol]>100 && m_copo[ycol]<200) {
 if (w3c) {
 mtmp=document.getElementById("Mx"+(m_copo[ycol]-101)+"y"+ycol);
 mtmp.firstChild.nodeValue=String.fromCharCode(160);
 mtem=document.getElementById("Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol);
 mtem.firstChild.nodeValue=String.fromCharCode(160);
 }
 else {
 mtmp=document.all["Mx"+(m_copo[ycol]-101)+"y"+ycol];
 mtmp.innerHTML=String.fromCharCode(160);
 mtem=document.all["Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol];
 mtem.innerHTML=String.fromCharCode(160);
 }
 setTimeout("zoomer("+ycol+")", speed);
 }
}
// -->
</SCRIPT>
<div id=matrix>I love u</div>

</center>
</body>
</html>

希望本文所述对大家的javascript程序设计有所帮助。

(0)

相关推荐

  • bat实现的模仿黑客帝国里面的数码雨

    ::黑客帝国里数码雨 @echo %dbg% off :: Code by redtek 2006-11-2 CMD@XP :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418 setlocal ENABLEDELAYEDEXPANSION mode con cols=80 lines=30 cls set 退格= set redtek=" " set end=0 :start set /a end+=1 call :ca

  • 黑客帝国数字雨效果VC6源代码分享

    很不错的效果 这个在Win7 X64 VC6编译通过~~ 代码原作者不详. #include <windows.h> #define ID_TIMER 1 #define STRMAXLEN 25 //一个显示列的最大长度 #define STRMINLEN 8 //一个显示列的最小长度 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; ////////////////////////////////////////////////

  • 批处理 数码雨代码解释

    做了一个批处理的数码雨,老题目了 主要给新手看 主要用于了解批处理的一下知识 1.随机变量的使用 2.变量的叠加 下面是源代码: 复制代码 代码如下: @echo off color 0a :start set num=0 set "echos= " :num set /a a1=%random%%%3 if "%a1%" == "1" set "a1= " if "%a1%" == "2&quo

  • 批处理实现乱雨纷飞(黑客帝国特效)

    废话少说,直接先上一个特效代码 @echo off&mode con cols=42 lines=20&color 02 set m=1&set v=1 set code==^^^&%%%^:!$#^>^<:=~*()@"'`;\|-_+?,.ghijklmnopqrstuvwxyz0123456789abcdef setlocal enabledelayedexpansion :begin set /a num=%random%%%40+1,num1

  • JS实现黑客帝国文字下落效果

    代码一: 黑客帝国文字下落效果 查看效果     源码下载 源代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>黑客帝国文字下落</title> <style> html, body {margin:0; padding:0; background-color:#000;} #divList {width:800px; h

  • jQuery模拟黑客帝国矩阵效果实例

    本文实例讲述了jQuery模拟黑客帝国矩阵效果的方法.分享给大家供大家参考.具体实现方法如下: html部分如下: <div id="container"> <div style="width:10px; word-break :break-all"> 10001001110010010010000 </div> <div style="width:10px; word-break :break-all;margi

  • js仿黑客帝国字母掉落效果代码分享

    看过黑客帝国的朋友或许都对开头的字幕效果很熟悉,自从影片播放以来,网页设计者有不少都在模仿这种字母掉落的效果,而且最后还有文字显现效果"I love you",你可以稍加修改,在情人节,用来对你的恋人表白哦~ 运行效果图: 大家也动手运行一下,                                      ----------------效果演示---------------- 为大家分享js仿黑客帝国字母掉落效果代码如下 <head> <meta htt

  • JS+CSS实现仿支付宝菜单选中效果代码

    本文实例讲述了JS+CSS实现仿支付宝菜单选中效果代码.分享给大家供大家参考.具体如下: 这是一个漂亮的JS+CSS仿支付宝菜单,总体风格和形式与支付宝的菜单没什么两样,细心会发现这是一个CSS爱好者自己手功完成的,自己美化图片,重写CSS代码,为作者给我们奉献这么好的菜单而表示感谢. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-css-f-alipay-style-menu-codes/ 具体代码如下: <!DOCTYPE html

  • JS+CSS实现仿msn风格选项卡效果代码

    本文实例讲述了JS+CSS实现仿msn风格选项卡效果代码.分享给大家供大家参考,具体如下: 这是一款来自MSN网站的选项卡,清新淡蓝色风格,新闻类.资讯类.文章类网站都比较适合使用,代码扩展性高,W3C标准设计,兼容IE.火狐等多种浏览器,整体效果非常不错. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-css-f-msn-style-menu-demo/ 具体代码如下: <!DOCTYPE html PUBLIC "-//W3C/

  • JS实现不使用图片仿Windows右键菜单效果代码

    本文实例讲述了JS实现不使用图片仿Windows右键菜单效果代码.分享给大家供大家参考,具体如下: 这里演示JS不使用图片仿Windows右键菜单效果,这款代码灵活使用了文鼎字,配合CSS和JS做出了这个和系统右键菜单很相似的东东. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-windows-right-button-menu-codes/ 具体代码如下: <HTML> <HEAD> <TITLE>极酷的多级右

  • JS实现拖动滚动条评分的效果代码分享

    小编教你JS特效拖动滚动条可以评分效果,小编感觉挺不错,用时候可能需要ASP/PHP或其它语言配合取值并写入数据库,这是前台的实现. 直接上代码 看看JS的神奇吧! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>

  • js仿京东轮播效果 选项卡套选项卡使用

    本文实例为大家分享了js仿京东轮播效果的具体代码,实现选项卡套用选项卡,供大家参考,具体内容如下 效果图: 代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{margin:0;padding:0;} ul{li

  • jQuery实现的仿百度分页足迹效果代码

    本文实例讲述了jQuery实现的仿百度分页足迹效果代码.分享给大家供大家参考,具体如下: 这是一个类似于百度的分页足迹效果,基于jquery,原理就是所有为奇数的足迹元素给不一样的样式而已,其它的非奇数元素就按默认的样式. 参数说明: obj为所有奇数元素 even当前所要点击触发事件 bg为足迹元素 active_bg为点击后的足迹背景 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/jquery-f-baidu-page-style-code

  • JS实现不规则TAB选项卡效果代码

    本文实例讲述了JS实现不规则TAB选项卡效果代码.分享给大家供大家参考.具体如下: 这是一款不规则TAB选项卡效果,将中规中矩的方角换成了不规则的圆角,也就是这一换,倒让浏览者新鲜了不少,也使选项卡增多了几份灵感,不是吗? 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-box-tab-nav-style-menu-codes/ 具体代码如下: <html> <head> <meta http-equiv="C

  • jQuery Ajax 异步加载显示等待效果代码分享

    AJAX 全称 Asynchronous JavaScript and XML(异步的 JavaScript 和 XML).它并非一种新的技术,而是以下几种原有技术的结合体. 1) 使用CSS和XHTML来表示. 2) 使用DOM模型来交互和动态显示. 3) 使用XMLHttpRequest来和服务器进行异步通信. 4) 使用javascript来绑定和调用. 通过AJAX异步技术,可以在客户端脚本与web服务器交互数据的过程中使用XMLHttpRequest对象来完成HTTP请求(Reques

  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码.分享给大家供大家参考,具体如下: 这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-db-click-src-scroll-style-codes/ 具体代码如下: <html> <SCRIPT language=JavaScript> var currentpos,ti

随机推荐