怎样改变层的大小?谢谢

BILLSJONE 2005-08-12 10:00:40
网页上有一个层<div>,和一个按扭,
按扭上设置长宽和位置数值,
那怎么样点击按扭就改变这个层的长和宽和这个层的位置为按扭设定的值?谢谢
...全文
76 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
BILLSJONE 2005-08-13
  • 打赏
  • 举报
回复
谢谢,可以了
adandelion 2005-08-13
  • 打赏
  • 举报
回复
楼主自己搜索吧在CSDN中"定位"
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>公文审批单打印</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<link rel="stylesheet" href="../putong_1t">
</HEAD>
<script language="javascript">
function doPrintSet()
{
//打印页面设置
objPrint.ExecWB(8,1);
}

//打印
function doPrint()
{
window.print();
}
function setDiv()
{
div1.style.width=width1.value;
div1.style.height=height1.value;
div1.style.position="relative";//相对位置
div1.style.posLeft =pLeft.value;
div1.style.posTop =pTop.value;
//alert("a");
}

</script>

<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=objPrint name=objPrint width=0></OBJECT>
<input type="button" value="set" onclick ="doPrintSet()">
<input type="button" value="set" onclick ="doPrint()">
width:<input type ="Text" id ="width1" name="width1">
height:<input type ="Text" id ="height1" name="height1">
left:<input type ="Text" id ="pLeft" name="pLeft">
right:<input type ="Text" id ="pTop" name="pTop">
<input type="button" value="setDiv" onclick ="setDiv()">
<div id ="div1" name ="div1" style="position:relative;left:Opx; top:Opx; width:280px;height:280px;border:1px RED Solid;">aaa</div>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var docWidth = document.body.clientWidth;
div1.style.position="absolute";//绝对位置
div1.style.width="300";
div1.style.height="250";
div1.style.posLeft ="0";
div1.style.posTop ="0";
//-->
</SCRIPT>
</HTML>
BILLSJONE 2005-08-12
  • 打赏
  • 举报
回复
我再想问问,
有时开始时我要个默位置,就是就是无论IE的大小怎么缩放,都让层在ie的左下角或右上角,怎么检测ie的右下角或左上角位置然后让层在那个位置呢?
BILLSJONE 2005-08-12
  • 打赏
  • 举报
回复
就是这样功能,谢谢adandelion(猪头)
adandelion 2005-08-12
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>公文审批单打印</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<link rel="stylesheet" href="../putong_1t">
</HEAD>
<script language="javascript">
function doPrintSet()
{
//打印页面设置
objPrint.ExecWB(8,1);
}

//打印
function doPrint()
{
window.print();
}
function setDiv()
{
div1.style.width=width1.value;
div1.style.height=height1.value;
div1.style.position="relative";//相对位置
div1.style.posLeft =pLeft.value;
div1.style.posTop =pTop.value;
//alert("a");
}
</script>

<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=objPrint name=objPrint width=0></OBJECT>
<input type="button" value="set" onclick ="doPrintSet()">
<input type="button" value="set" onclick ="doPrint()">
width:<input type ="Text" id ="width1" name="width1">
height:<input type ="Text" id ="height1" name="height1">
left:<input type ="Text" id ="pLeft" name="pLeft">
right:<input type ="Text" id ="pTop" name="pTop">
<input type="button" value="setDiv" onclick ="setDiv()">
<div id ="div1" name ="div1" style="position:relative;left:Opx; top:Opx; width:280px;height:280px;border:1px RED Solid;">aaa</div>
</BODY>
</HTML>
这里使用了相对位置。
adandelion 2005-08-12
  • 打赏
  • 举报
回复
<link rel="stylesheet" href="../putong_1t">
</HEAD>
<script language="javascript">
function doPrintSet()
{
//打印页面设置
objPrint.ExecWB(8,1);
}

//打印
function doPrint()
{
window.print();
}
function setDiv()
{
div1.style.width=width1.value;
div1.style.height=height1.value;
//alert("a");
}
</script>

<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=objPrint name=objPrint width=0></OBJECT>
<input type="button" value="set" onclick ="doPrintSet()">
<input type="button" value="set" onclick ="doPrint()">
width:<input type ="Text" id ="width1" name="width1">
height:<input type ="Text" id ="height1" name="height1">
<input type="button" value="setDiv" onclick ="setDiv()">
<div id ="div1" name ="div1" style="position:relative;left:Opx; top:Opx; width:280px;height:280px;border:1px RED Solid;">aaa</div>
</BODY>
</HTML>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧