JS 网页彩蛋 实现代码
作者:bea
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; chars
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css">
.bg{ background:url(http://nba.titan24.com/focus/kikx/images/sp.gif) repeat;}
p{ text-align:center; color:#d00; padding:10px 0; }
h1{ text-align:center; font-size:80px; color:#f06; line-height:120px;}
</style>
</head>
<body>
<p>按 ↑ ↑ ↓ ↓ ← ← → → </p>
</body>
<script type="text/javascript">
function trick(e){
if(typeof window.k=="undefined"){
window.k=""
}
var e=e||event;
//alert(e.keyCode);
if(e.keyCode==116) window.k="";
window.k+=e.keyCode+",";
if(window.k=="38,38,40,40,37,37,39,39,") {
play();
window.k="";
}
}
function play(){
var bdy=document.getElementsByTagName("body")[0];
var p=bdy.getElementsByTagName("p")[0];
var h1=document.createElement("h1");
h1.innerHTML="Hello!!!!!";
bdy.className="bg";
p.style.display="none";
bdy.appendChild(h1);
window.setTimeout("clean()",5000);
}
function clean(){
var bdy=document.getElementsByTagName("body")[0];
var p=bdy.getElementsByTagName("p")[0];
bdy.className="";
p.style.display="";
var h1=bdy.getElementsByTagName("h1")[0];
bdy.removeChild(h1);
}
document.onkeydown=trick;
</script>
</html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- javascript 基础简介 适合新手学习
- 一个简单的JavaScript 日期计算算法
- 关于javascript 回调函数中变量作用域的讨论
- 用DIV完美模拟createPopup 弹出窗口(),支持Firefox,ie,chrome
- javascript 一些用法小结
- JS 日期验证正则附asp日期格式化函数
- jquery 简单导航实现代码
- 禁止JQuery中的load方法装载IE缓存中文件的方法
- 一个用javascript写的select支持上下键、首字母筛选以及回车取值的功能
- 用Javascript 和 CSS 实现脚注(Footnote)效果
- Javascript 获取滚动条位置等信息的函数
- 用Javascript实现锚点(Anchor)间平滑跳转
- 用 Javascript 验证表单(form)中的单选(radio)值
- 用 Javascript 验证表单(form)中多选框(checkbox)值
- Javascript String.replace的妙用
- Javascript 检测、添加、移除样式(className)函数代码
- Javascript 阻止浏览器默认操作的实现代码
- javascript 流畅动画实现原理
- javascript 定义初始化数组函数