我想增加的行里的iframe的地址由前一个行的按钮来确定,规律嘛,地址我一定要能在编排网页时自定义修改,网页编好后,由每一个按钮控制。
解决方案 »
- jpa 列名无效
- .vm 后缀的是什么网页? 用什么编辑
- 怎样将一篇长的文章存入数据库,然后又原模原样的展现在页面上呢???
- 启动Tomcat后,发布Web模块出错(struts+sping+hibernate整和)!
- 遇到一个form.submit和window.close先后次序的问题。
- javascript问题急:醒目
- 如何将JavaScript的一些值通过JSP存入数据库?
- 如何将string转化成int
- 如何在jsp页面中输出oracle的clob类型的数据?一定要用oci连接吗??
- 哪里有dreamweaver mx软件的下载,装上就能直接用的那种
- 菜鸟问题
- 各位大侠,如何提取JSP页面中的一些数据
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>全自动增加</title>
</head><body topMargin=0 bottomMargin=0>
<form name="theForm" method="post" action="aaa.jsp">
<table align="center" width=100% id="DataItem" border="0" bgcolor=#ff0000 cellpadding="0" cellspacing="0">
<tr><td id="aaa" align="center">
1<input type="button" name="check" value="增加一个" onclick="addRow();"><input type='button' value='删除这个' class='button' onclick='deleteRow()'>
<iframe src='http://www.sina.com.cn' width=100% height=30 marginwidth=0 marginheight=0 frameborder=0 scrolling=No noresize=noresize></iframe>
</td></tr>
</table>
</from>
<script language="javascript">
aaa.height= (window.screen.availHeight-200)/10;
function addRow()
{
if(DataItem.rows.length==1)
url="http://www.163.com";
if(DataItem.rows.length==2)
url="http://www.chinaren.com";
if(DataItem.rows.length==3)
url="http://www.sohu.com";
if(DataItem.rows.length==4)
url="http://www.163.com";
var oRow1 = DataItem.insertRow(DataItem.rows.length);
var aRows = DataItem.rows;
var aCells= oRow1.cells;
var oCell1_2=aRows(oRow1.rowIndex).insertCell(aCells.length);
innerhtml1 = DataItem.rows.length+"<input type='button' name='check' value='增加一个' onclick='addRow();'><input type='button' value='删除这个' class='button' onclick='deleteRow()'>";
oCell1_2.innerHTML = innerhtml1 +"<iframe src='"+url+"' width=100% height=100 marginwidth=0 marginheight=0 frameborder=0 scrolling=No noresize=noresize></iframe>";
oCell1_2.align = "center";
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(DataItem.rows.length-1);
for(i=1;i<DataItem.rows.length;i++)
{
DataItem.rows[i].height = height1;
}
}
//删除行
function deleteRow()
{
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(DataItem.rows.length-2);
for(i=1;i<DataItem.rows.length;i++)
{
if(DataItem.rows.length!=2)
DataItem.rows[i].height = height1;
}
var tr;
tr = event.srcElement.parentElement.parentElement;
DataItem.deleteRow(tr.rowIndex);
}
</script>
</body>
</html>控制代码是这一段
if(DataItem.rows.length==1)
url="http://www.163.com"; //新增的第一行时的地址
if(DataItem.rows.length==2)
url="http://www.chinaren.com"; //新增的第二行时的地址
if(DataItem.rows.length==3)
url="http://www.sohu.com"; //新增的第三行时的地址
if(DataItem.rows.length==4)
url="http://www.163.com"; //新增的第四行时的地址
以此类推
应该很容易看懂吧
oCell1_2.align = "center";
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(DataItem.rows.length-1);
改为
oCell1_2.align = "center";
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(DataItem.rows.length-1);
oCell1_2.innerHTML = "<iframe src='"+url+"' width=100% height='"+height1+"' marginwidth=0 marginheight=0 frameborder=0 scrolling=No noresize=noresize></iframe>";
就可以让iframe的高和行的高一样了,不过这样的话,那几个按钮你想放在哪里呢
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>全自动增加</title>
</head><body topMargin=0 bottomMargin=0>
<form name="theForm" method="post" action="aaa.jsp">
<table align="center" width=100% id="DataItem" border="1" bgcolor=#ff0000 cellpadding="0" cellspacing="0">
<tr><td id="aaa" align="center">
<iframe src='kkkk.html' width=100% height=30 marginwidth=0 marginheight=0 frameborder=0 scrolling=No noresize=noresize></iframe>
</td></tr>
</table>
</from>
<script language="javascript">
aaa.height= (window.screen.availHeight-200)/10;
function addRow()
{
url="kkkk.html";
if(DataItem.rows.length==1)
url="kkkk.html";
if(DataItem.rows.length==2)
url="kkkk.html";
if(DataItem.rows.length==3)
url="kkkk.html";
if(DataItem.rows.length==4)
url="kkkk.html";
var oRow1 = DataItem.insertRow(DataItem.rows.length);
var aRows = DataItem.rows;
var aCells= oRow1.cells;
var oCell1_2=aRows(oRow1.rowIndex).insertCell(aCells.length);
oCell1_2.innerHTML = "<iframe src='"+url+"' width=100% height=100 marginwidth=0 marginheight=0 frameborder=0 scrolling=No noresize=noresize></iframe>";
oCell1_2.align = "center";
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(DataItem.rows.length-1);
for(i=1;i<DataItem.rows.length;i++)
{
DataItem.rows[i].height = height1;
//alert(DataItem.rows[i].height);
}
}
//删除行
function deleteRow(kkk)
{
clientHeight= document.body.offsetHeight;
height1 = clientHeight/10*9/(kkk-2);
for(i=1;i<kkk-1;i++)
{
if(DataItem.rows.length!=2)
DataItem.rows[i].height = height1;
}
DataItem.deleteRow(kkk-1);
}
</script>
</body>
</html>kkkk.html内容
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>全自动增加</title>
</head><body topMargin=0 bottomMargin=0 bgcolor=#ff0000>
<table align="center" width=100% id="DataItem" border="0" bgcolor=#ff0000 cellpadding="0" cellspacing="0">
<tr><td id="aaa" align="center">
1<input type="button" name="check" value="增加一个" onclick="window.parent.addRow();"><input type='button' value='删除这个' class='button' onclick='window.parent.deleteRow(window.parent.DataItem.rows.length)'>
</td></tr>
</table>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>全自动增加</title>
</head><body>
<form name="theForm" method="post" action="aaa.jsp">
<table align="center" width=100% height=100% id="DataItem" border="1">
<tr><td id="aaa" align="center" height=100% >
1<input type="button" name="check" value="增加一个" onclick="addRow();"><input type='button' value='缩小' class='button' onclick='smallRow()'><input type='button' value='放大' class='button' onclick='bigRow()'>
<div id="diyi" height=100% >
<iframe src='http://www.sina.com' width=100% height=30 marginwidth=0 marginheight=0 frameborder=0 scrolling=atuo noresize=noresize></iframe>
</div>
</td></tr>
</table>
</from>
<script language="javascript">//增加行
function addRow()
{
var strFileName;
var oRow1 = DataItem.insertRow(DataItem.rows.length);
var aRows = DataItem.rows;
var aCells= oRow1.cells;
var oCell1_2=aRows(oRow1.rowIndex).insertCell(aCells.length);
oCell1_2.innerHTML = DataItem.rows.length+"<input type='button' name='check' value='增加一个' onclick='addRow();'><input type='button' value='删除这个' class='button' onclick='deleteRow()'>";;
oCell1_2.align = "center";
clientHeight= window.screen.availHeight-200;
height1 = clientHeight/10*6.8/(DataItem.rows.length);
for(i=1;i<DataItem.rows.length;i++)
{
aaa.height= height1;
DataItem.rows[i].height = height1;
}
}//删除行
function deleteRow()
{
var tr;
tr = event.srcElement.parentElement.parentElement;
DataItem.deleteRow(tr.rowIndex);
clientHeight= window.screen.availHeight-200;
height1 = clientHeight/10*8/(DataItem.rows.length-1); //调节10*8的8这个数字控制高度变化
for(i=1;i<DataItem.rows.length;i++)
{
DataItem.rows[i].height = height1;
}
}//缩小
function smallRow(){
aaa.height= (window.screen.availHeight-200)/50;
diyi.style.display="none";
clientHeight= window.screen.availHeight-200;
height1 = clientHeight/10*8.8/(DataItem.rows.length-1);
for(i=1;i<DataItem.rows.length;i++)
{
DataItem.rows[i].height = height1;
}
}//放大
function bigRow(){
diyi.style.display="block";
clientHeight= window.screen.availHeight-200;
height1 = clientHeight/10*6.8/(DataItem.rows.length);
for(i=1;i<DataItem.rows.length;i++)
{
DataItem.rows[i].height = height1;
}
}
</script>
</body>
</html>***这是我改过的,添加删除有错?不知道错在哪里?请指点。