Js版Windows窗口模拟,兼容FF火狐,可拖动,可改变大小
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>窗口模拟--Author:Vibo Email:vibo_cn@hotmail.com</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, 宋体;
font-size: 12px;
}
.webWinFrame {
position: absolute;
left:15px;
top:15px;
padding: 3px;
background-color: #EEEEEE;
}
.webWin {
width: 300px;
border: 1px solid #80C65A;
background-color: #FFFFFF;
}
.webWin .wTitle{
line-height: 18px;
padding: 2px;
font-weight: bold;
cursor:move;
background-color: #DDF8CC;
/*display:inline-block;*/
white-space: nowrap;
overflow:hidden;
text-overflow:ellipsis
}
.webWin .wContent {
overflow:hidden;
}
.webWin .wResizeBox {
background-color: #80C65A;
height: 5px;
width: 5px;
position: absolute;
right: 5px;
bottom: 5px;
overflow:hidden;
cursor:se-resize;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
</head>
<body>
<div class="webWinFrame" id="testWinA"><div class="webWin"><div class="wTitle">TitleA-ViboStudio</div><div class="wContent">
<!---->
<div style="width:300px;height:200px;padding:2px;">
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
此处显示新 Div 标签的内容此处显示新 Div 标签的内容<br>
</div>
<!---->
</div><div class="wResizeBox"></div></div></div>
<div class="webWinFrame" id="testWinB" style="top:110px;"><div class="webWin"><div class="wTitle">TitleB</div><div class="wContent">
<!---->
此处显示新 Div 标签的内容
此处显示新 Div 标签的内容
此处显示新 Div 标签的内容
<!---->
</div><div class="wResizeBox"></div></div></div>
</body>
</html>
<script>
window.$ = function(obj){return (document.getElementById)?document.getElementById(obj):(document.all)?document.all[obj]:obj}
window.isIE = window.Event?false:true;
window.getMouseCoords=function(e){return {x:isIE?e.clientX+Math.max(document.body.scrollLeft, document.documentElement.scrollLeft):e.pageX,y:isIE?e.clientY+Math.max(document.body.scrollTop, document.documentElement.scrollTop):e.pageY};}
window.vWinZIndex = 1;
function vDrag(o,ho,initArr){
ho=ho||o;
o.style.position="absolute";
if(!isIE){ho.firstChild.onmousedown=function(){return false;}}
ho.onmousedown=function(a){
o.style.zIndex = window.vWinZIndex;
window.vWinZIndex++;
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(ho.setCapture)
ho.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=function(a){
if(!a)a=window.event;
var mus=getMouseCoords(a)
if(!a.pageX)a.pageX=mus.x;
if(!a.pageY)a.pageY=mus.y;
var tx=a.pageX-x,ty=a.pageY-y;
if(initArr){
o.style.left=(tx<initArr[0]?initArr[0]:tx>initArr[2]?initArr[2]:tx)+"px";
o.style.top=(ty<initArr[1]?initArr[1]:ty>initArr[3]?initArr[3]:ty)+"px";
}else{
o.style.left = tx+"px";