我想增加的行里的iframe的地址由前一个行的按钮来确定,规律嘛,地址我一定要能在编排网页时自定义修改,网页编好后,由每一个按钮控制。

解决方案 »

  1.   

    <html>
    <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";  //新增的第四行时的地址
    以此类推
    应该很容易看懂吧
      

  2.   

    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);
    改为
       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的高和行的高一样了,不过这样的话,那几个按钮你想放在哪里呢
      

  3.   

    高手,按钮放在iframe中哟,你没有把按钮放在iframe中,不然我怎么控制增加呢?你现在代码,我在iframe中按钮调用父页的函数后增加的行不能和上一行平分高度
      

  4.   

    <html>
    <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>
      

  5.   

    <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>***这是我改过的,添加删除有错?不知道错在哪里?请指点。