主题:什么东西啊.改变不了大小.
linxuanxu
[专家分:9360] 发布于 2007-07-31 15:39:00
<!-- 看见个标记ilayer挺有趣的,可是为什么改变不了大小? -->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
<!--
function onInformation(){
var theNum= parseInt(document.all.layer1.width)
theNum+=10;
document.all.layer1.width = theNum;
alert(document.all.layer1.width);
}
-->
</script>
</head>
<body>
<div>
<ilayer bgcolor="red" id="layer1" name="layerName1" left="266" top="60" width="176" height="119" >
<table width="100" height="100%">
<tr height="20">
<td height="24" bgcolor="#0033FF"></td>
</tr>
<tr height="180" valign="top">
<td bgcolor="#99FF99" >
<h3>Hello</h3>
<input type="text" />
<input type="button" onclick="return onInformation();"/> </td>
</tr>
</table>
</ilayer>
</div>
</body>
</html>
回复列表 (共7个回复)
沙发
wangsdong [专家分:21390] 发布于 2007-07-31 16:45:00
<script language="javascript" type="text/javascript">
<!--
function onInformation(){
theNum=parseInt(document.getElementById("layer1").width);
theNum+=parseInt(document.form1.aaa.value);
document.getElementById("layer1").setAttribute("width",theNum);
}
-->
</script>
<div id="la">
<ilayer bgcolor="red" name="layerName1" width="200" height="119" >
<table width="100" height="100%" id="layer1">
<form name="form1" method="post">
<tr height="20">
<td height="24" bgcolor="#0033FF"></td>
</tr>
<tr height="180" valign="top">
<td bgcolor="#99FF99" >
<h3>Hello</h3>
<input type="text" name="aaa" size=10/>
<input type="button" onclick="return onInformation();" value="扩大"/> </td>
</tr>
</form>
</table>
</ilayer>
</div>
试试
板凳
linxuanxu [专家分:9360] 发布于 2007-07-31 16:52:00
NB
不过还有的问,
<ilayer left="234" top="20" width="200" height="119" >
在DM里面位置是一个样,但是运行后什么总是感觉 top=0 了 left=0 了. 当然JavaScript输出该属性仍然是 left="234" top="20" 怎么回事.多谢老大了
3 楼
wangsdong [专家分:21390] 发布于 2007-07-31 17:34:00
<script language="javascript" type="text/javascript">
<!--
function onInformation(){
theNum=parseInt(document.getElementById("layer1").width);
theNum+=parseInt(document.form1.aaa.value);
document.getElementById("layer1").setAttribute("width",theNum);
}
-->
</script>
<div id="la" style="LEFT: 200px; TOP:60px;POSITION: absolute;">
<ilayer bgcolor="red" name="layerName1" width="200" height="119">
<table width="100" height="300" id="layer1">
<form name="form1" method="post">
<tr height="20">
<td height="24" bgcolor="#0033FF"></td>
</tr>
<tr height="180" valign="top">
<td bgcolor="#99FF99" >
<h3>Hello</h3>
<input type="text" name="aaa" size=10/>
<input type="button" onclick="return onInformation();" value="扩大"/> </td>
</tr>
</form>
</table>
</ilayer>
</div>
4 楼
linxuanxu [专家分:9360] 发布于 2007-08-01 09:32:00
谢谢不过还想问一下:为什么无法通过改变Top值而动态改变定点位置.为什么无法通过改变Left值而动态改变左边距位置.
即是说:改变Width.和Height就可以看见动态效果:而Top,Left无论怎么改都不行.?
这是怎么回事,该如何解决.谢谢了
5 楼
wangsdong [专家分:21390] 发布于 2007-08-01 10:06:00
<script language="javascript" type="text/javascript">
<!--
function onInformation(){
theNum=parseInt(document.getElementById("layer1").width);
theNum+=parseInt(document.form1.aaa.value);
document.getElementById("layer1").setAttribute("width",theNum); document.getElementById("layer1").style.left=parseInt(document.getElementById("layer1").style.left.replace("px",""))+100;
}
-->
</script>
<div id="la">
<ilayer bgcolor="red" name="layerName1" width="200" height="119">
<table width="100" height="300" id="layer1" style="LEFT: 200px; TOP:60px;POSITION: absolute;">
<form name="form1" method="post">
<tr height="20">
<td height="24" bgcolor="#0033FF"></td>
</tr>
<tr height="180" valign="top">
<td bgcolor="#99FF99" >
<h3>Hello</h3>
<input type="text" name="aaa" size=10/>
<input type="button" onclick="return onInformation();" value="扩大"/> </td>
</tr>
</form>
</table>
</ilayer>
</div>
6 楼
longlong16 [专家分:10670] 发布于 2007-08-01 10:25:00
NB!
7 楼
linxuanxu [专家分:9360] 发布于 2007-08-01 10:47:00
真正的高手.
加不了分了.谢谢.
我来回复