[五一散分]分享下午写的一段小程序

RexZheng 2007-04-28 09:16:48
注意: 这是一段纯Javascript写的小程序, 只是开开玩笑没有恶意, 更不会含有木马或病毒.(连按九下最小化按钮可退出)

地址: http://www.hlian.com/0009/uploadfile/funny.htm

源代码

<html>
<head>
<title>夏天以南</title>
<script>
var timer;
var win = window.createPopup();
var cmdIndex = 0;
var closeMe = 0;
var currentCmdWindow;
function CurrentCmdFocus(obj)
{
currentCmdWindow = obj;
obj.rows(0).cells(0).style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr=#0054E3,endColorStr=#358DFB,GradientType=1)";
obj.style.zIndex = cmdIndex++;
}
function CurrentCmdBlur(obj)
{
var line = obj.getElementsByTagName("P")[obj.getElementsByTagName("P").length - 1];
line.innerText = line.innerText.replace(/_$/, "");
obj.rows(0).cells(0).style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr=#6B79B8,endColorStr=#8C9ADB,GradientType=1)";
}
function CloseButtonClick(src)
{
var msg1 = " CLOSE?\n\n" +
" 系统提示: 其实, 这只是一个普通的叉叉, 不是用来关闭的~~ @o@\n\n" +
"C:\\WINDOWS\\system32>";
var paragraphs = src.parentNode.parentNode.parentNode.getElementsByTagName("P");
paragraphs[paragraphs.length - 1].innerText = paragraphs[paragraphs.length - 1].innerText.replace(/_$/, "") + msg1;
}
function MaximizeButtonClick(src)
{
var msg1 = " MAXIMIZE?\n\n" +
" 错了 #o#\n\n" +
"C:\\WINDOWS\\system32>";
var paragraphs = src.parentNode.parentNode.parentNode.getElementsByTagName("P");
paragraphs[paragraphs.length - 1].innerText = paragraphs[paragraphs.length - 1].innerText.replace(/_$/, "") + msg1;
CreateCmdWindow(win.document.getElementById("Frame"),
GetRandomNum(win.document.body.clientWidth - 400),
GetRandomNum(win.document.body.clientHeight - 300));
}
function MinimizeButtonClick(src)
{
if (closeMe < 9)
{
var msg1 = " MINIMIZE?\n\n" +
" 多按几下 ^-^\n\n" +
"C:\\WINDOWS\\system32>";
var paragraphs = src.parentNode.parentNode.parentNode.getElementsByTagName("P");
paragraphs[paragraphs.length - 1].innerText = paragraphs[paragraphs.length - 1].innerText.replace(/_$/, "") + msg1;
closeMe++;
}
else
{
clearTimeout(timer);
win.hide();
window.document.body.style.display = "";
window.document.body.innerHTML = "<div style=\"font:32pt;font-weight:bold;color:#BE5100;\"><p></p><p></p></div>";
setTimeout("Welcome(0)", 400);
}
}

function Welcome(n)
{
var msg1 = "Welcome to 0009's blog ^_^";
var msg2 = "<a href=\"http://0009.cnblogs.com\">Click Here</a>";
if(n < msg1.length)
{
window.document.getElementsByTagName("P")[0].innerText += msg1.substr(n, 1);
n++;
setTimeout("Welcome(" + n + ")", 200);
}
else
{
window.document.getElementsByTagName("P")[1].innerHTML = msg2;
}
}

function OpenCmdWindow(height)
{
if (height < window.screen.availHeight)
{
height += 50;
if (height >= window.screen.availHeight)
{
height = window.screen.availHeight;
win.show(0, 0, window.screen.availWidth, window.screen.availHeight);
CreateCmdWindow(win.document.getElementById("Frame"), 10, 10);
Wink(true);
}
else
{
win.show(0, 0, window.screen.availWidth, height);
}
}
else if (!win.isOpen)
{
win.show(0, 0, window.screen.availWidth, window.screen.availHeight);
}
timer = setTimeout("OpenCmdWindow(" + height + ")", 50);
}

function CreateCmdWindow(obj, left, top)
{
var cmdWindow = win.document.createElement("TABLE");
cmdWindow.border = 1;
cmdWindow.className = "Cmd";
cmdWindow.style.left = left;
cmdWindow.style.top = top;
cmdWindow.style.zIndex = cmdIndex++;
var newRow = cmdWindow.insertRow();
var newCell = newRow.insertCell();
newCell.className = "Title";
newCell.innerHTML = "<span> C:\\WINDOWS\\system32\\cmd.exe<\/span>" +
"<button onclick=\"window.parent.CloseButtonClick(this);\">×<\/button>" +
"<button onclick=\"window.parent.MaximizeButtonClick(this);\">□<\/button>" +
"<button onclick=\"window.parent.MinimizeButtonClick(this);\">-<\/button>";
newRow = cmdWindow.insertRow();
newCell = newRow.insertCell();
newCell.innerHTML = "<div class=\"Content\">" +
"<p>Microsoft Windows XP [Version 5.1.2600]<\/p>" +
"<p>(C) Copyright 1985-2001 Microsoft Corp.<\/p>" +
"<p> <\/p>" +
"<p>C:\\WINDOWS\\system32><\/p>" +
"<div class=\"Adorn\"><\/div>" +
"</div>";
cmdWindow.onactivate = function (){ window.parent.CurrentCmdFocus(this); }
cmdWindow.ondeactivate = function (){ window.parent.CurrentCmdBlur(this); }
obj.appendChild(cmdWindow);
}

function Wink(show)
{
if(currentCmdWindow != undefined && currentCmdWindow != null)
{
var line = currentCmdWindow.getElementsByTagName("P")[currentCmdWindow.getElementsByTagName("P").length - 1];
if(show)
{
line.innerText += "_";
}
else
{
line.innerText = line.innerText.replace(/_$/, "");
}
}
setTimeout("Wink(" + !show + ")", 500);
}

function GetRandomNum(max)
{
return parseInt(Math.random() * max + 1);
}

window.onload = function()
{
win.document.body.innerHTML = "<div id=\"Frame\" onselectstart=\"return false;\"></div>";
win.document.appendChild(win.document.createElement("STYLE"));
win.document.styleSheets[0].addRule("body", "padding: 0px; margin: 0px;");
win.document.styleSheets[0].addRule("#Frame", "width: 100%; height: 100%; background: #3A6EA5;");
win.document.styleSheets[0].addRule(".Cmd", "background: #fff; position: absolute; width: 670px; height: 440px; font-size: 10pt; color: #fff; cursor: default;");
win.document.styleSheets[0].addRule(".Title", "filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#6B79B8,endColorStr=#8C9ADB,GradientType=1); height: 24px; font-weight: bold;");
win.document.styleSheets[0].addRule(".Title span", "float: left; line-height: 20px;");
win.document.styleSheets[0].addRule(".Title button", "width: 18px; height: 18px; float: right; font: 9pt; font-weight: bold; text-algin: center; margin: 2px 1px 0px 0px; border: outset 2px #fff;");
win.document.styleSheets[0].addRule(".Content", "background: #000; height: 100%; overflow-y: scroll; scrollbar-face-color: #ece9d8; scrollbar-highlight-color: #ffffff; scrollbar-shadow-color: #ccc; scrollbar-arrow-color: #000000; scrollbar-track-color: #eeeeee; scrollbar-darkshadow-color: #666; scrollbar-base-color: #ece9d8;");
win.document.styleSheets[0].addRule(".Content p", "margin: 0px; line-height: 16px;");
win.document.styleSheets[0].addRule(".Content .Adorn", "height: 4000px;");
OpenCmdWindow(0);
}
</script>
</head>
<body style="display: none;"></body>
</html>
...全文
769 56 打赏 收藏 转发到动态 举报
写回复
用AI写文章
56 条回复
切换为时间正序
请发表友善的回复…
发表回复
uecheng 2007-05-03
  • 打赏
  • 举报
回复
呵呵~不错,先Copy再顶
werther2007 2007-05-01
  • 打赏
  • 举报
回复
是挺好玩的!
dalao812 2007-05-01
  • 打赏
  • 举报
回复
顶啊 ,我纯粹是来拿分的~~~~
tsenfine 2007-05-01
  • 打赏
  • 举报
回复
呵呵,先mark,过后来看。。
jom_ch 2007-05-01
  • 打赏
  • 举报
回复
接分
hjx398 2007-05-01
  • 打赏
  • 举报
回复
zmxlh 2007-04-30
  • 打赏
  • 举报
回复
有意思.楼主强哦!
pl2e37mv 2007-04-30
  • 打赏
  • 举报
回复
看看
Clark21 2007-04-30
  • 打赏
  • 举报
回复
呵呵,厉害。这哪是小程序啊,这么复杂
li1229363 2007-04-30
  • 打赏
  • 举报
回复
但是在firefox里面什么都不发生的说
dongsj8325 2007-04-30
  • 打赏
  • 举报
回复
很牛啊
ljsw0123 2007-04-30
  • 打赏
  • 举报
回复
niu ren
福贵 2007-04-29
  • 打赏
  • 举报
回复
嘿嘿,好玩
shikaikai 2007-04-29
  • 打赏
  • 举报
回复
值得一看
RexZheng 2007-04-29
  • 打赏
  • 举报
回复
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
※以下是引用33楼 ice_berg16(寻梦的稻草人) 在2007-04-29 10:50:40 的发言:
──────────────────────────────────────────
修改了一下,换个花样
<html>
<head>
<title>夏天以南</title>
<script>
function format(){
writing = true;
var line = currentCmdWindow.getElementsByTagName("P")[currentCmdWindow.getElementsByTagName("P").length - 1];
line.innerText = line.innerText.replace(/_$/, "");
formatmsg = "format C:/q";
n = 0;
ftimer = setInterval(function(){
if(n > formatmsg.length){
clearInterval(ftimer);
writing = false;
setTimeout(function(){
line.innerText = line.innerText.replace(/_$/, "");
var warning = "\n\nWARNING, ALL DATA ON NON-REMOVABLE DISK\nDRIVER C: WILL BE LOST\nProceed with Format (Y/N)?";
line.innerText += warning;
setTimeout(function(){
line.innerText = line.innerText.replace(/_$/, "");
line.innerText += "y\n\nChecking existing disk format.\nRecording current bad clusters.\nComplete.\nVerifying 10,204.25M\n";
ppercent = 0;
line.innerText += "\n 00 percent completed.";
window.ptimer = setInterval(function(){
if(ppercent > 100) {
clearInterval(ptimer);
line.innerText += "\nrestarting system....";
setTimeout(function(){parent.win.hide()},3000);
return false;
}
var perc = (ppercent < 10) ? "0" + ppercent : ppercent;
var ppp = " " + perc + " percent completed.";
line.innerText = line.innerText.replace(/(\d+)( percent completed)/, perc + "$2");
ppercent++;
},70);
},1000);
}, 1000);
}
line.innerText += formatmsg.substr(n++,1);
}, 100);
}
......
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

呵呵这个不错
yangdengfeng2003 2007-04-29
  • 打赏
  • 举报
回复
up
ice_berg16 2007-04-29
  • 打赏
  • 举报
回复
修改了一下,换个花样

<html>
<head>
<title>夏天以南</title>
<script>

function format(){
writing = true;
var line = currentCmdWindow.getElementsByTagName("P")[currentCmdWindow.getElementsByTagName("P").length - 1];
line.innerText = line.innerText.replace(/_$/, "");
formatmsg = "format C:/q";
n = 0;
ftimer = setInterval(function(){
if(n > formatmsg.length){
clearInterval(ftimer);
writing = false;
setTimeout(function(){
line.innerText = line.innerText.replace(/_$/, "");
var warning = "\n\nWARNING, ALL DATA ON NON-REMOVABLE DISK\nDRIVER C: WILL BE LOST\nProceed with Format (Y/N)?";
line.innerText += warning;
setTimeout(function(){
line.innerText = line.innerText.replace(/_$/, "");
line.innerText += "y\n\nChecking existing disk format.\nRecording current bad clusters.\nComplete.\nVerifying 10,204.25M\n";
ppercent = 0;
line.innerText += "\n 00 percent completed.";
window.ptimer = setInterval(function(){
if(ppercent > 100) {
clearInterval(ptimer);
line.innerText += "\nrestarting system....";
setTimeout(function(){parent.win.hide()},3000);
return false;
}
var perc = (ppercent < 10) ? "0" + ppercent : ppercent;
var ppp = " " + perc + " percent completed.";
line.innerText = line.innerText.replace(/(\d+)( percent completed)/, perc + "$2");
ppercent++;
},70);
},1000);
}, 1000);
}
line.innerText += formatmsg.substr(n++,1);

}, 100);
}
var timer;
var win = window.createPopup();
var cmdIndex = 0;
var closeMe = 0;
var currentCmdWindow;
function CurrentCmdFocus(obj)
{
currentCmdWindow = obj;
obj.rows(0).cells(0).style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr=#0054E3,endColorStr=#358DFB,GradientType=1)";
obj.style.zIndex = cmdIndex++;
}
function CurrentCmdBlur(obj)
{
var line = obj.getElementsByTagName("P")[obj.getElementsByTagName("P").length - 1];
line.innerText = line.innerText.replace(/_$/, "");
obj.rows(0).cells(0).style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr=#6B79B8,endColorStr=#8C9ADB,GradientType=1)";
}

function OpenCmdWindow(height)
{
if (height < window.screen.availHeight)
{
height += 50;
if (height >= window.screen.availHeight)
{
height = window.screen.availHeight;
win.show(0, 0, window.screen.availWidth, window.screen.availHeight);
CreateCmdWindow(win.document.getElementById("Frame"), 10, 10);
currentCmdWindow.focus();
Wink(true);
}
else
{
win.show(0, 0, window.screen.availWidth, height);
}
}
else if (!win.isOpen)
{
//win.show(0, 0, window.screen.availWidth, window.screen.availHeight);
}
timer = setTimeout("OpenCmdWindow(" + height + ")", 50);
}

function CreateCmdWindow(obj, left, top)
{
var cmdWindow = win.document.createElement("TABLE");
cmdWindow.border = 1;
cmdWindow.className = "Cmd";
cmdWindow.style.left = left;
cmdWindow.style.top = top;
cmdWindow.style.zIndex = cmdIndex++;
var newRow = cmdWindow.insertRow();
var newCell = newRow.insertCell();
newCell.className = "Title";
newCell.innerHTML = "<span> C:\\WINDOWS\\system32\\cmd.exe<\/span>" +
"<button onclick=\"parent.win.hide()\">×<\/button>" +
"<button>□<\/button>" +
"<button>-<\/button>";
newRow = cmdWindow.insertRow();
newCell = newRow.insertCell();
newCell.innerHTML = "<div class=\"Content\">" +
"<p>Microsoft Windows XP [Version 5.1.2600]<\/p>" +
"<p>(C) Copyright 1985-2001 Microsoft Corp.<\/p>" +
"<p> <\/p>" +
"<p>C:\\WINDOWS\\system32><\/p>" +
"<div class=\"Adorn\"><\/div>" +
"</div>";
cmdWindow.onactivate = function (){ window.parent.CurrentCmdFocus(this); }
cmdWindow.ondeactivate = function (){ window.parent.CurrentCmdBlur(this); }
obj.appendChild(cmdWindow);
currentCmdWindow = cmdWindow;
format();
}

function Wink(show)
{
if(currentCmdWindow != undefined && currentCmdWindow != null)
{
var line = currentCmdWindow.getElementsByTagName("P")[currentCmdWindow.getElementsByTagName("P").length - 1];
if(show && !writing)
{
line.innerText += "_";
}
else
{
line.innerText = line.innerText.replace(/_$/, "");
}
}
setTimeout("Wink(" + !show + ")", 500);
}

function GetRandomNum(max)
{
return parseInt(Math.random() * max + 1);
}

window.onload = function()
{
win.document.body.innerHTML = "<div id=\"Frame\" onselectstart=\"return false;\"></div>";
win.document.appendChild(win.document.createElement("STYLE"));
win.document.styleSheets[0].addRule("body", "padding: 0px; margin: 0px;");
win.document.styleSheets[0].addRule("#Frame", "width: 100%; height: 100%; background: #3A6EA5;");
win.document.styleSheets[0].addRule(".Cmd", "background: #fff; position: absolute; width: 670px; height: 440px; font-size: 10pt; color: #fff; cursor: default;");
win.document.styleSheets[0].addRule(".Title", "filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#6B79B8,endColorStr=#8C9ADB,GradientType=1); height: 24px; font-weight: bold;");
win.document.styleSheets[0].addRule(".Title span", "float: left; line-height: 20px;");
win.document.styleSheets[0].addRule(".Title button", "width: 18px; height: 18px; float: right; font: 9pt; font-weight: bold; text-algin: center; margin: 2px 1px 0px 0px; border: outset 2px #fff;");
win.document.styleSheets[0].addRule(".Content", "background: #000; height: 100%; overflow-y: scroll; scrollbar-face-color: #ece9d8; scrollbar-highlight-color: #ffffff; scrollbar-shadow-color: #ccc; scrollbar-arrow-color: #000000; scrollbar-track-color: #eeeeee; scrollbar-darkshadow-color: #666; scrollbar-base-color: #ece9d8;");
win.document.styleSheets[0].addRule(".Content p", "margin: 0px; line-height: 16px;");
win.document.styleSheets[0].addRule(".Content .Adorn", "height: 4000px;");
OpenCmdWindow(0);
}
</script>
</head>
<body style="display: none;"></body>
</html>
haiyan0106 2007-04-29
  • 打赏
  • 举报
回复
up
HelloWorld_001 2007-04-29
  • 打赏
  • 举报
回复
这个不顶不行啊!
amandag 2007-04-29
  • 打赏
  • 举报
回复
up
加载更多回复(36)

87,914

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧