62,072
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DOM_text01</title>
<style type="text/css">
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height:25px;
line-height:25px;
text-align:center;
font-weight:bold;
border: 2px solid #849BCA;
display:block;
color:#547BC9;
float:left;
text-decoration:none;
margin-top:2px;
}
a.od:link{
background:#EEF1F8;
}
a.od:visited{
background:#EEF1F8;
}
a.od:hover{
background:#EEE;
}
a.od:active{
background:#EEE;
}
#fd{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:2px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
/*filter:alpha(opacity=50);*/
}
.content{
padding:10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="bodyL">
<a href="#" class="od" onclick = "show('fd');return false;">
[打开层]
</a>
<a href="#" class="od" onclick = "closeed('fd');return false;">
[关闭层]
</a>
</div>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id) {/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function() { openx(o, 500) }, 10);
}
function openx(o, x) {/*--打开x--*/
var cx = parseInt(o.style.width);
if (cx < x) {
o.style.width = (cx + Math.ceil((x - cx) / 5)) + "px";
}
else {
clearInterval(prox);
proy = setInterval(function() { openy(o, 200) }, 10);
}
}
function openy(o, y) {/*--打开y--*/
var cy = parseInt(o.style.height);
if (cy < y) {
o.style.height = (cy + Math.ceil((y - cy) / 5)) + "px";
}
else {
clearInterval(proy);
}
}
function closeed(id) {/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if (o.style.display == "block") {
proyc = setInterval(function() { closey(o) }, 10);
}
}
function closey(o) {/*--打开y--*/
var cy = parseInt(o.style.height);
if (cy > 0) {
o.style.height = (cy - Math.ceil(cy / 5)) + "px";
}
else {
clearInterval(proyc);
proxc = setInterval(function() { closex(o) }, 10);
}
}
function closex(o) {/*--打开x--*/
var cx = parseInt(o.style.width);
if (cx > 0) {
o.style.width = (cx - Math.ceil(cx / 5)) + "px";
}
else {
clearInterval(proxc);
o.style.display = "none";
}
}
/*-------------------------鼠标拖动---------------------*/
var od = document.getElementById("fd");
var dx, dy, mx, my, mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmouseover = function(e) {
var e = e ? e : event;
if (e.button == (document.all ? 1 : 0)) {
mouseD = true;
}
}
document.onmouseup = function() {
mouseD = false;
odrag = "";
if (isIE) {
od.releaseCapture();
od.filters.alpha.opacity = 100;
}
else {
window.releaseEvents(od.MOUSEMOVE);
od.style.opacity = 1;
}
}
//function readyMove(e){
od.mousedown = function(e) {
odrag = this;
var e = e ? e : event;
if (e.button == (document.all ? 1 : 0)) {
mx = e.clientX;
my = e.clientY;
od.style.left = od.offsetLeft + "px";
od.style.top = od.offsetTop + "px";
if (isIE) {
od.setCapture();
od.filters.alpha.opacity = 50;
}
else {
window.captureEvents(Event.MOUSEMOVE);
od.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e) {
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if (mouseD == true && odrag) {
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.style.left = parseInt(od.style.left) + mrx + "px";
od.style.top = parseInt(od.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script>
</form>
</body>
</html>
//*****************************************************************************
//以下代码为封装弹出层JS代码
//*****************************************************************************
var parentElement = parent.rootElement != undefined ? parent : window;
var rootElement = parentElement.rootElement != undefined ? parentElement.rootElement : parentElement;
var LayerNumber = 0;
function LcLayer(idstring) {
var Layer = new Object;
LayerNumber = LayerNumber + 1;
var oBody = document.body;
var bgDiv = null;
var oDiv = null;
var x0 = 0, y0 = 0, x1 = 0, y1 = 0;
var offx = 6, offy = 6;
var isdraging = false;
//属性定义
Layer.LayerTitle = "-";
Layer.TitleColor = "#a6c1f7";
Layer.Border = "2px solid #6c97cc";
Layer.Background = "#ffffff";
Layer.CloseColor = "#0000ff";
Layer.LayerType = 0;
Layer.LayerUrl = "about:blank";
Layer.LayerHTML = "";
Layer.Scrolling = "auto";
Layer.Padding = 6;
Layer.IsReLoad = false;
Layer.GetResult = 0;
Layer.SetResult = "";
Layer.Width = 400;
Layer.Height = 300;
//初始化层
Layer.open = function() {
var loadflag = this.IsReLoad;
bgDiv = document.createElement("div");
bgDiv.id = "WinLayer" + LayerNumber;
bgDiv.className = "layerbg";
bgDivBg = document.createElement("div");
bgDivBg.className = "layerbgbg";
bgDiv.appendChild(bgDivBg);
oDiv = document.createElement("div");
oDiv.id = idstring;
oDiv.style.backgroundColor = this.Background;
oDiv.className = "layerbody";
oDiv.style.width = this.Width;
oDiv.style.height = this.Height;
var oTitleTable = document.createElement("TABLE");
oTitleTable.style.width = "100%";
oTitleTable.style.height = "100%";
oTitleTable.border = "0";
oTitleTable.cellPadding = "0";
oTitleTable.cellSpacing = "0";
var oTitle = oTitleTable.insertRow();
oTitle.height = 30;
oTitle.style.backgroundColor = this.TitleColor;
oTitle.insertCell();
oTitle.cells(0).style.paddingLeft = '10px';
oTitle.cells(0).innerHTML = this.LayerTitle;
oTitle.cells(0).onmousedown = function() {
this.style.cursor = "move";
this.setCapture();
x0 = event.clientX;
y0 = event.clientY;
x1 = parseInt(oDiv.style.left);
y1 = parseInt(oDiv.style.top);
isdraging = true;
}
oTitle.cells(0).onmousemove = function() {
if (isdraging) {
var x = x1 + event.clientX - x0;
var y = y1 + event.clientY - y0;
var xx = document.body.clientWidth - oDiv.offsetWidth - offx;
var yy = document.body.clientHeight - oDiv.offsetHeight - offy;
if (x <= offx) x = offx;
if (y <= offy) y = offy;
if (x >= xx) x = xx;
if (y >= yy) y = yy;
oDiv.style.left = x;
oDiv.style.top = y;
}
}
oTitle.cells(0).onmouseup = function() {
this.style.cursor = "auto";
isdraging = false;
this.releaseCapture();
}
oTitle.insertCell();
oTitle.cells(1).id = idstring + '_Close';
oTitle.cells(1).style.width = 54;
oTitle.cells(1).style.textAlign = 'center';
oTitle.cells(1).style.color = this.CloseColor;
oTitle.cells(1).style.fontSize = '12px';
oTitle.cells(1).style.cursor = 'pointer';
oTitle.cells(1).innerHTML = "【关闭】";
oTitle.cells(1).onclick = function() {
//CloseLayer(idstring);
if (loadflag == true) document.location.replace(document.location.href);
var oBodyc = document.body;
var oDivc = document.getElementById(idstring);
var obgDivc = oDivc.parentElement;
if (obgDivc) obgDivc.style.display = 'none';
oBodyc.removeChild(obgDivc);
obgDivc = null;
}
var oTable = document.createElement("TABLE");
oTable.style.width = "100%";
oTable.style.height = "100%";
oTable.style.border = this.Border;
oTable.cellPadding = "0";
oTable.cellSpacing = "0";
var oTableHeader = oTable.insertRow();
oTableHeader.height = 30;
oTableHeader.insertCell();
oTableHeader.cells(0).appendChild(oTitleTable);
var oDivContentTable = document.createElement("TABLE");
oDivContentTable.style.width = "100%";
oDivContentTable.style.height = "100%";
oDivContentTable.style.border = "0";
oDivContentTable.cellPadding = "0";
oDivContentTable.cellSpacing = "0";
var oContentRow = oDivContentTable.insertRow();
oContentRow.insertCell();
oContentRow.cells(0).width = this.Padding;
var iframehtml = this.LayerHTML;
if (this.LayerType == 0) {
iframehtml = "<iframe id='" + idstring + "_Frame' name='" + idstring + "_Frame' style='width:100%;height:100%;' ";
iframehtml += "src='" + this.LayerUrl + "' marginwidth='0' marginheight='0' ";
iframehtml += "frameBorder='0' scrolling='auto'></iframe>";
}
else {
var htmlstr = "<div style='width:100%;height:100%;overflow:auto;line-height:1.3;'>";
htmlstr += iframehtml;
htmlstr += "<div>";
iframehtml = htmlstr;
}
oContentRow.insertCell();
oContentRow.cells(1).innerHTML = iframehtml;
oContentRow.insertCell();
oContentRow.cells(2).width = this.Padding;
var oTopRow = oTable.insertRow();
oTopRow.insertCell();
oTopRow.cells(0).height = this.Padding;
var oDivContent = oTable.insertRow();
oDivContent.insertCell();
oDivContent.cells(0).height = "100%";
oDivContent.cells(0).appendChild(oDivContentTable);
var oBottomRow = oTable.insertRow();
oBottomRow.insertCell();
if (this.LayerType == 2) {
oBottomRow.cells(0).height = 50;
oBottomRow.cells(0).style.textAlign = "center";
var BottomMsgBtn = document.createElement("INPUT");
BottomMsgBtn.type = "button";
BottomMsgBtn.value = " 确定 ";
BottomMsgBtn.onclick = function() {
CloseLayer(idstring);
}
oBottomRow.cells(0).appendChild(BottomMsgBtn);
}
else {
oBottomRow.cells(0).height = this.Padding;
}
oDiv.appendChild(oTable);
bgDiv.appendChild(oDiv);
oBody.appendChild(bgDiv);
if (bgDiv) bgDiv.style.display = 'block';
if (oDiv) oDiv.style.display = 'block';
}
return Layer;
}
//关闭弹出层
function CloseLayer(idstring) {
//var oBody = document.body;
//var oDiv = document.getElementById(idstring);
//var obgDiv = oDiv.parentElement;
//if (obgDiv) obgDiv.style.display = 'none';
//oBody.removeChild(obgDiv);
//obgDiv = null;
var oClose = document.getElementById(idstring + "_Close");
if(oClose) oClose.click();
}
<script src="../../Inc/Layer.js" type="text/javascript"></script>
<script type="text/javascript">
GroupsSelect("hdnGroupsCode");
function operCent(needId, needType, vendCode,flag,pactid) {
var Layer_Cent = new rootElement.LcLayer('Layer_Cent');//新建个层
Layer_Cent.LayerUrl = "Cent.aspx?needType=" + needType + "&needId=" + needId + "&vendCode=" + vendCode + "&flag=" + flag + "&pactid=" + pactid;//弹出层里面的页面路径
Layer_Cent.IsReLoad = true;
Layer_Cent.Width = 700;//设置层的宽
Layer_Cent.Height = 470;
Layer_Cent.open();//打开
}
</script>
<!--重新改了下,刚才不兼容ff,现在ie6 7 8 ff opera都测试可以-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DOM_text01</title>
<style type="text/css">
body, span, div, td
{
font-size: 12px;
line-height: 1.5em;
color: #849BCA;
}
#bodyL
{
float: left;
width: 84px;
margin-right: 2px;
}
a.od
{
width: 80px;
height: 25px;
line-height: 25px;
text-align: center;
font-weight: bold;
border: 2px solid #849BCA;
display: block;
color: #547BC9;
float: left;
text-decoration: none;
margin-top: 2px;
}
a.od:link
{
background: #EEF1F8;
}
a.od:visited
{
background: #EEF1F8;
}
a.od:hover
{
background: #EEE;
}
a.od:active
{
background: #EEE;
}
#fd
{
width: 500px;
height: 200px;
background: #EDF1F8;
border: 2px solid #849BCA;
margin-top: 2px;
margin-left: 2px;
float: left;
overflow: hidden;
position: absolute;
left: 0px;
top: 0px;
cursor: move;
float: left; /*filter:alpha(opacity=50);*/
}
.content
{
padding: 10px;
}
</style>
</head>
<body>
<form runat="server">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<div id="bodyL">
<a href="#" class="od" onclick="show('fd');return false;">[打开层] </a><a href="#" class="od"
onclick="closeed('fd');return false;">[关闭层] </a>
</div>
<div id="fd" style="display: none; filter: alpha(opacity=100); opacity: 1;">
<div id="head" style="height: 30px; background: red; width: 100%;">
</div>
<div class="content" style="z-index: 9999; border: 1px solid #ccc;">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Text1" type="text" />
</div>
</div>
</form>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,200)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
/*-------------------------鼠标拖动---------------------*/
var od = document.getElementById("head");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e){
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function(){
mouseD = false;
odrag = "";
if(isIE)
{
od.parentNode.releaseCapture();
od.parentNode.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.parentNode.style.opacity = 1;
}
}
//function readyMove(e){
od.onmousedown = function(e){
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.parentNode.style.left = od.parentNode.offsetLeft + "px";
od.parentNode.style.top = od.parentNode.offsetTop + "px";
if(isIE)
{
od.parentNode.setCapture();
od.parentNode.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
od.parentNode.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e){
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.parentNode.style.left = parseInt(od.parentNode.style.left) +mrx + "px";
od.parentNode.style.top = parseInt(od.parentNode.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script>
</body>
</html>
<!--帮你改了下,加了个头部,现在是按住头部才可以拖动,因为你写的按住层的话会缩定,这样就不能输入!-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DOM_text01</title>
<style type="text/css">
body, span, div, td
{
font-size: 12px;
line-height: 1.5em;
color: #849BCA;
}
#bodyL
{
float: left;
width: 84px;
margin-right: 2px;
}
a.od
{
width: 80px;
height: 25px;
line-height: 25px;
text-align: center;
font-weight: bold;
border: 2px solid #849BCA;
display: block;
color: #547BC9;
float: left;
text-decoration: none;
margin-top: 2px;
}
a.od:link
{
background: #EEF1F8;
}
a.od:visited
{
background: #EEF1F8;
}
a.od:hover
{
background: #EEE;
}
a.od:active
{
background: #EEE;
}
#fd
{
width: 500px;
height: 200px;
background: #EDF1F8;
border: 2px solid #849BCA;
margin-top: 2px;
margin-left: 2px;
float: left;
overflow: hidden;
position: absolute;
left: 0px;
top: 0px;
cursor: move;
float: left; /*filter:alpha(opacity=50);*/
}
.content
{
padding: 10px;
}
</style>
</head>
<body>
<form runat="server">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<div id="bodyL">
<a href="#" class="od" onclick="show('fd');return false;">[打开层] </a><a href="#" class="od"
onclick="closeed('fd');return false;">[关闭层] </a>
</div>
<div id="fd" style="display: none; filter: alpha(opacity=100); opacity: 1;">
<div id="head" style="height: 30px; background: red; width: 100%;">
</div>
<div class="content" style="z-index: 9999; border: 1px solid #ccc;">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Text1" type="text" />
</div>
</div>
</form>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,200)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
/*-------------------------鼠标拖动---------------------*/
var od = document.getElementById("head");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e){
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function(){
mouseD = false;
odrag = "";
if(isIE)
{
od.parentElement.releaseCapture();
od.parentElement.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.parentElement.style.opacity = 1;
}
}
//function readyMove(e){
od.onmousedown = function(e){
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.parentElement.style.left = od.parentElement.offsetLeft + "px";
od.parentElement.style.top = od.parentElement.offsetTop + "px";
if(isIE)
{
od.parentElement.setCapture();
od.parentElement.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
od.parentElement.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e){
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.parentElement.style.left = parseInt(od.parentElement.style.left) +mrx + "px";
od.parentElement.style.top = parseInt(od.parentElement.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script>
</body>
</html>
<input type="text" onclick="this.focus();"/> 这样就可以了