JS 网页彩蛋 实现代码
.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;}
按 ↑ ↑ ↓ ↓ ← ← → →
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;
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]