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 ?<a?href="http://www.tmcode.net/">
http://www.tmcode.net</a><br?/>
<br?/>
參數:
<hr>
高度: ?<input?type="text"?id="ht"?size="7"><br?/>
寬度: ?<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?/>
標題: ?<input?type="text"?id="tt"?size="25"><br?/>
內容: ?<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 閱讀(407)
評論(0) 編輯 收藏 所屬分類:
JavaScript 、
HTML