本人用 iframe 做了一个tab页.代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="budgetList.aspx.cs" Inherits="Report_budgetList" %><html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>项目立项列表</title>
    <link rel="stylesheet" href="../css/css.css" type="text/css" />    <script language="javascript" type="text/javascript" src="../js/jscontrol.js"></script>    <style type="text/css">
        body
        {
            overflow: hidden;
        }
        .tdClass
        {
            border-left: 1px solid #BCD2E6;
            border-right: 1px solid #BCD2E6;
            border-top: 1px solid #BCD2E6;
            border-bottom: 1px solid #BCD2E6;
            cursor: pointer;
        }
    </style>    <script type="text/javascript">  
   
        function setTdBackGroundColor(tdColor1,tdColor2,tdColor3){
            document.getElementById("tdproBudgetProList").style.backgroundColor=tdColor1;
            document.getElementById("tdproBudgetProChangeList").style.backgroundColor=tdColor2; 
            document.getElementById("tdbudgetExecStatusReportDetails").style.backgroundColor=tdColor3;
        }  
      function SelectElement(tdElement)
      {
        tdElement.style.backgroundColor="";
        var passUrl="budgetExecStatusQuery.aspx";
        switch(tdElement.id.toString()){ //设着色
            case "tdproBudgetProList":
                setTdBackGroundColor("#ffffff","#cae8f8","#cae8f8");
            break;
            case "tdproBudgetProChangeList":
                setTdBackGroundColor("#cae8f8","#ffffff","#cae8f8");
            break;
            case "tdbudgetExecStatusReportDetails":
                setTdBackGroundColor("#cae8f8","#cae8f8","#ffffff");
            break;
            
          } 
        var spanElement=tdElement.getElementsByTagName("span");
        if(spanElement!=null){ //设url
            switch(spanElement[0].id.toString()){
                case "lblproBudgetProList":
                   passUrl="budgetExecStatusQuery.aspx";
                break;
                case "lblproBudgetProChangeList":
                   passUrl="budgetExecStatusReport.aspx";
                break;
                case "lblbudgetExecStatusReportDetails":
                    passUrl="budgetExecStatusReportDetails.aspx";
                break;
              
            }
       } 
         document.getElementById("frameAuditMain").src=passUrl;
      }    
      function onLoad(){
          document.getElementById("frameAuditMain").src="budgetExecStatusQuery.aspx";
      }
    </script></head>
<body onload="onLoad();">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <table align="center" border="0" cellpadding="0" cellspacing="0" style="height: 100%;
        width: 100%;">
        <tr class="siteMap">
            <td>
                &nbsp;<img alt="" src="../images/icon.gif" />
                &nbsp;当前位置:
                <asp:SiteMapPath ID="SiteMapPath1" runat="server" PathSeparator=" &gt;&gt;">
                </asp:SiteMapPath>
            </td>
        </tr>
        <tr style="height: 21px;">
            <td align="left">
                <table border="0" cellpadding="0" cellspacing="0" style="height: 100%; width: 100%;">
                    <tr>
                        <td id="tdproBudgetProList" onclick="SelectElement(this);" class="tdClass" style="width: 100px;"
                            align="center">
                            <asp:Label ID="lblproBudgetProList" runat="server" Style="color: #003755;" Text="预算执行情况查询"></asp:Label>
                        </td>
                        <td id="tdproBudgetProChangeList" onclick="SelectElement(this);" class="tdClass"
                            align="center" style="background-color: #cae8f8; width: 120px;">
                            <asp:Label ID="lblproBudgetProChangeList" runat="server" Style="color: #003755;"
                                Text="预算执行情况统计表"></asp:Label>
                        </td>
                        <td id="tdbudgetExecStatusReportDetails" onclick="SelectElement(this);" class="tdClass"
                            align="center" style="background-color: #cae8f8; width: 100px;">
                            <asp:Label ID="lblbudgetExecStatusReportDetails" runat="server" Style="color: #003755;"
                                Text="预算执行情况明细"></asp:Label>
                        </td>
                        <td style="border-bottom: 1px solid #d3d3d3;">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="width: 100%;">
                <iframe id="frameAuditMain" runat="server" frameborder="0" height="100%" width="100%"
                    scrolling="auto" src=""></iframe>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>问题如下:我在budgetExecStatusReport.aspx页里怎么获取到通 budgetList.aspx 页面里的 某个ID,比如说:tdbudgetExecStatusReportDetails?

解决方案 »

  1.   


    window.top.document.getElementById("tdbudgetExecStatusReportDetails")
      

  2.   

    获取 不到 夸页面的 ID吧只能传值。值保存关键信息,,
     当你点击 iframe1 的 某控件,可 传值过去,并刷新 iframe2,然后根据值,做你需要的操作!
      

  3.   

    <form>
    <input id="aaa"/>
    <iframe id="frameAuditMain" src="bbbb.aspx"></iframe>
    </form>在 bbbb.aspx 页面
    JS :function fun()
    {
        if(window.top != undefined)
        {
            var a = window.top.document.getElementById("aaa")
        }
    }
    可以取得到帮 LZ测试!呵呵
      

  4.   

    试试
    window.parent.document.getElementById("tdbudgetExecStatusReportDetails")