Javascript模拟的DOS窗口

2016-02-19 22:19 46 1 收藏

有了下面这个Javascript模拟的DOS窗口教程,不懂Javascript模拟的DOS窗口的也能装懂了,赶紧get起来装逼一下吧!

【 tulaoshi.com - Web开发 】

  源代码

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?" +
    "    系统提示: 其实, 这只是一个普通的叉叉, 不是用来关闭的~~ " +
    "C:WINDOWSsystem32";
    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?" +
    "    错了 #o#" +
    "C:WINDOWSsystem32";
    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?" +
        "    多按几下 ^-^" +
        "C:WINDOWSsystem32";
        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/pp/p/div";
        setTimeout("Welcome(0)", 400);
    }
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

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:WINDOWSsystem32cmd.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"" +
        "pMicrosoft windows xp [Version 5.1.2600]/p" +
        "p(C) Copyright 1985-2001 Microsoft Corp./p" +
        "p /p" +
        "pC:WINDOWSsystem32>/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);
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

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

来源:https://www.tulaoshi.com/n/20160219/1628175.html

延伸阅读
win7系统怎么进入DOS窗口?   方法一: 1、点击开始搜索在搜索框中输入cmd命令后按回车; 2、在搜索结果中双击打开CMD即可。 PS:如果用户经过优化后,不支持搜索功能的话,可依次进入--开始-程序-附件。 方法二: 1、使用Win+R快捷键打开运行窗口; win7系统任务栏弹出错误提示USB root hub怎么办 &...
如何模拟《WORD》的窗口形式 作者:lanzhengpeng2 提交者:eastvc 发布日期:2004-1-2 20:47:45 原文出处:http://www.csdn.net/ 如何模拟《WORD》的窗口形式重点在CChildFrame上做文章。 1、利用向导生成一个多文档应用程序 TestMDI,则生成下列类: CAboutDlg,CChildFrame,CMainFrame,CTestMDIApp,CTestMDIDoc,CTestMDIView 2、改...
标签: Web开发
JavaScript是基于对象的脚本编程语言,那么它的输入输出就是通过对象来完成的。其中有关输入可通过窗口(Window)对象来完成,而输出可通过文档(document)对象的方法来实现。 一、窗口及输入输出 请看下面例子: HTMLHeadscript languaga="JavaScript"Var test=window.prompt("请输入数据:");docume...
标签: Web开发
虽然和本blog的内容无关,但是还是写出来吧,希望对大家有帮助 前几天在博客园看到有人说模态窗口在ie7里面显示出现地址栏,其实这本是一件好事,而且ie的模态窗口是ie的函数,ff、opera等都不支持,我评论的原话 只是ie7增强的安全特性罢了,这个世界还真奇怪,有人说ie的安全性不强,天天骂微软,还支持ff说什么用了ff就不会被强奸,微软增...
标签: Web开发
一、引言 在C#和Java语言中,面向对象是以类的方式实现的,特别是继承这个特性,类的方式继承表现出了强大的功能,而且也易于学习。javascript不是纯的面向对象的语言,而是基于对象的语言,对象的继承是以原型函数的形式继承的,很多初学者刚开始接触的时候不太理解,但是JavaScript这种以原型函数的形式实现面向对象技术,不仅是可行的...

经验教程

384

收藏

39
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部