`
xieye
  • 浏览: 807782 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

简陋的js控制台

    博客分类:
  • PHP
 
阅读更多
function debug_1()
{
    //alert(33)
var str =
    '<center><h2 style="color:red;font-size:18px;">console</h2></center>'+
    '<textarea readonly="readonly" id="log_output" ' +
              'style="width:99%;height:100px;background:black;color:white;font-family:\'Courier New\'">12333erw'+
    '</textarea>'+
    '<div>命令输入<input type="text" value="" id="c_input" style="width:400px;height:30px;font-family:\'Courier New\'" />' +
       '<input type="button" value="执行" onclick="eval(document.getElementById(\'c_input\').value)">' +
       '<input type="button" value="清除控制台" onclick="document.getElementById(\'log_output\').value=\'\';"></div>' ;
   
   
    var div = document.createElement('div');
    div.id = "console_id";
    div.style.cssText = 'position:absolute;left:0;top:440px;display:none;' +
                        'background:white;border:2px solid blue;z-index:9999';
    div.innerHTML = str;
    //document.body.insertBefore(div,document.body.firstChild);
    document.body.appendChild(div);
    //alert(44)
//document.body.onclick=function(){alert(0)}

document.body.onkeyup =function (){
        //var event= g_EventUtil.getEvent();
      //  alert(22)
if (event.keyCode != 71)return;
        //alert(event.keyCode);
        if (event.altKey){
            if (document.getElementById('console_id').style.display!='none')
              document.getElementById('console_id').style.display='none';
            else
              document.getElementById('console_id').style.display='';
        }
      };
 
   
   
}
function log(text)
{
    var area = document.getElementById('log_output');
    area.value += '\n' + text;
    area.scrollTop += area.offsetHeight;
}
//Event.observe(window, 'load', debug_1);

window.onload = debug_1; //alt + g 打开控制台
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics