posts - 22,comments - 35,trackbacks - 0
html 源文件:vwindow.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="Microsoft FrontPage 6.0">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<link rel="stylesheet" href="vwindow.css" />
<script language="javascript" type="text/javascript">
function show()
{
    
var v_ht = parseInt(document.getElementById("ht").value);
    
var v_wd = parseInt(document.getElementById("wd").value);
    
var v_co_x = parseInt(document.getElementById("cooX").value);
    
var v_co_y = parseInt(document.getElementById("cooY").value);
    
var v_tt = document.getElementById("tt").value;
    
var v_main = document.getElementById("main").value;
    
var v_st = document.getElementById("st").value;
    showvw(v_ht,v_wd,v_co_y,v_co_x,v_tt,v_main,
0,v_st);
}
</script>
</head>

<body>
<script language="JavaScript" src="vwindow.js"></script>
虚拟窗口--jat 2005-05-15
&nbsp; <href="http://www.tmcode.net/">
http://www.tmcode.net
</a><br />
<br />
参数:

<hr>
高度:
&nbsp; <input type="text" id="ht" size="7"><br />
宽度:
&nbsp; <input type="text" id="wd" size="7"><br />
坐标X: 
<input type="text" id="cooX" size="7"><br />
坐标Y: 
<input type="text" id="cooY" size="7"><br />
标题:
&nbsp; <input type="text" id="tt" size="25"><br />
内容:
&nbsp; <textarea id="main" rows="6" cols="41" ></textarea><br />
状态栏:
<input type="text" id="st" size="25"><p>
<br />
<button onclick="show()" style="width: 254px; height: 26px">显示</button>

</p>
<p>

<br />
<font color="#FF00FF">CTRL+D</font> 调出调试窗口,详细参数见vwindow.js注释,请自行更改vwindow.css样式</p>
</body>
</html>


css 样式:vwindow.css
#vwin {background-color:#ffcc66;border:outset 1px;position:absolute;visibility:hidden;width:300px;height:200px;cursor:crosshair;}
#vwTit
{background-color:#3399FF;}
#vwTitle 
{color:#ffffff;font-size:10pt;font-weight:bold;text-align:left;}
#vwStatus 
{background-color:#88ddff;font-size:9pt;}
#vwText 
{background-color:#88ddff;border:0px;font-size:9pt;padding:8px;}
table
{word-break:break-all;}


javascript :vwindow.js
/**
 * 虚拟窗口
 * 制作:jat
 * 2005-05-15
*
*/
var inivw
var tbx;
var tby;

inivw 
= "<div id='vwin'>";
/***标题栏***/
inivw 
+= "<table cellspacing='0' cellpadding='0' border='0' width='100%' id='vwTit'>";
inivw 
+= "<tr><td id='vwIcon' width='25'><img src='image/bomber.gif' border='0' height='25' width='25' ondblclick='hidevw()'></td><td id='vwTitle' onmousemove='dr_mv()' onmousedown='xy();setCapture()' onmouseup='releaseCapture()'>title</td><td id='vwButton' align='right' width='25'><img src='image/error.gif' border='0' height='25' width='25' alt='关闭' onclick='hidevw()'></td></tr>";
inivw 
+= "</table>";
/***标题栏***/

/***内容区***/
inivw 
+= "<table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>";
inivw 
+= "<tr><td id='vwText' valign='top'></td></tr>";
inivw 
+= "</table>";
/***内容区***/

/***状态栏***/
inivw 
+= "<table cellspacing='0' cellpadding='0' border='0' width='100%' height='20' >";
inivw 
+= "<tr><td id='vwStatus'>rrr</td></tr>";
inivw 
+= "</table>";
/***状态栏***/

inivw 
+= "</div>";
document.write(inivw);
inivw 
= "";
function showvw(Ht,Wd,Tp,Lt,Tt,Txt,Icon,stat,name)   //showvw(高度,宽度,垂直坐标,水平坐标,标题,内容,图标,状态栏信息)
 {
  
var vwHeight;
  
var vwWidth;
  
var vwTop;
  
var vwLeft;
  
var vwTitle;
  
var vwIcon;
  
var vwText;
  
var vwStat;

  
if(Ht && Ht > 30)
   vwHeight 
= Ht;
  
else
   vwHeight 
= 150;
  
if(Wd && Wd > 100)
   vwWidth 
= Wd;
  
else
   vwWidth 
= 400;
  
if(Tp && Tp > 0)
   vwTop 
= Tp;
  
else
   vwTop 
= Math.max(Math.round((document.body.offsetHeight-vwHeight)/2),0);
  
if(Lt && Lt > 0)
   vwLeft 
= Lt;
  
else
   vwLeft 
= Math.max(Math.round((document.body.offsetWidth-vwWidth)/2),0);
  
if(Tt)
   vwTitle 
= Tt;
  
else
   vwTitle 
= "无标题";
  
if(Txt)
   vwText 
= Txt;
  
else
   vwText 
= "无内容";
  
if(stat)
   vwStat 
= stat;
  
else
   vwStat 
= "";
  document.getElementById(
"vwin").style.height = vwHeight;
  document.getElementById(
"vwin").style.width = vwWidth;
  document.getElementById(
"vwin").style.left = vwLeft;
  document.getElementById(
"vwin").style.top = vwTop;
  document.getElementById(
"vwTitle").innerText = vwTitle;
  document.getElementById(
"vwText").innerHTML = vwText;
  document.getElementById(
"vwStatus").innerHTML = vwStat;
  document.getElementById(
"vwin").style.visibility = "visible";
 }
function xy()
 {
  tbx 
= event.offsetX + 29;
  tby 
= event.offsetY + 4;
 }
function dr_mv()
{
  
if(event.button==1)
   {
   document.getElementById(
"vwin").style.left = document.body.scrollLeft + event.clientX-tbx;
   document.getElementById(
"vwin").style.top = document.body.scrollTop + event.clientY-tby;
   }
}
function hidevw()
 {
  document.getElementById(
"vwin").style.visibility = "hidden";
 }
function run_script()
{
    
var msg = "";
    
var cmd;
    
var type;
    
var txt = document.getElementById("in_cmd").value;
    
try
    {
        cmd 
= eval(txt);
        type 
= typeof (cmd);
    }
    
catch(e)
    {
        cmd 
= "";
        type 
= "";
        msg 
= "输入的变量不存在,请检查变量名,注意大小写!";
    }
    
if(type === "string")
        msg 
= "长度:"+cmd.length;
    
if(cmd === null)
        msg 
= "变量为空值!";
    
if(cmd === undefined)
        msg 
= "变量未初始化!";
    alert(
"值:"+cmd+"\n"+"类型:"+type+"\n"+msg);
}
function debug()
{
    
if(event.ctrlKey && event.keyCode == 68)
        {
        
var DBG_txt = "";
        DBG_txt 
+= "<br /><center><b>请输入命令</b><br /><input type=\"text\" style=\"text-align:center;\" value=\"\" size=40 id=in_cmd><br /><input type=\"button\" value=\"显示/运行\" onclick=\"run_script()\">";
        DBG_txt 
+= "</center>";
        showvw(
31,350,0,0,"Debug",DBG_txt,"debug.gif","");
        document.getElementById(
"in_cmd").focus();
        }
}
document.body.onkeydown 
= debug;

posted on 2006-06-30 11:05 kelven 阅读(399) 评论(0)  编辑  收藏 所属分类: JavaScriptHTML

只有注册用户登录后才能发表评论。


网站导航: