现在的位置: 首页 > 综合 > 正文

asp.net做系统时,经典的上左右Iframe

2013年07月18日 ⁄ 综合 ⁄ 共 1531字 ⁄ 字号 评论关闭

  不知不觉,我已经工作的有一年半了,第一个公司呆的有三个月,第一个公司一直呆到现在现在,做的系统也不少了。发觉做系统时,还是喜欢用Iframe,而且是很经典的上左右Iframe,如下图

                    

   常见的用法是top处放图片,显示系统的Logo,退出系统,返回首页功能;left处放置菜单,点击某一个选项后,让right处显示相应的界面;与left、right中间有一个分割标准,点击一下left隐藏,再点击一下left显示。

   这样的好处是,当显示右边页面数据时,我们只会刷新right处数据,而top与left处不用刷新,减少网络流量传送。如果是做商务网站的话,肯定不会用Iframe,因为网络爬虫似乎对Iframe处的数据不感兴趣。现在的公司用了母版页,感觉有点似乎不如Iframe。

   那么,如何完成整个页面的功能呢,你自己可以先想想。、

   对于我所在的公司来说,能够熟练使用Div人太少,界面布局还是使用传统的Table布局,下面这段是Table布局的。

<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td colspan="3" height="100" bgcolor="red" >top</td>
        </tr>
        <tr>
            <td width="190" id="frmTitle" noWrap="noWrap" name=fmTitle" valign="top" height="100%">
                <iframe height="100%" width="100%" frameborder="0" src="left.aspx"
                    name="leftFrame"></iframe>
            </td>
            <td width="6" style="width: 6px; background: #1568b4" valign="middle" 
                height="100%">
                <span  id="switchPoint" title="关闭/打开侧边栏">
                    <label onclick="switchSysBar()" style="cursor:pointer;">click</label>
                </span>
            </td>
            <td valign="top" width="100%" height="100%">
                <iframe height="100%" width="100%" frameborder="0" name="center" src="right.aspx">
                </iframe>
            </td>
        </tr>
    </table>

  为了实现点击在left让右边的页面显示,我们需要特别注意右边的Iframe的name值,因为这个值很重要,无论是<a href="" target="">中的target还是window.open("",target)的target都是指定这个Iframe的name值,也就是说,打开的目标是在这个值里面的。不知道我的讲解是否明白。

  其次,关闭打开的方法其实也就是将id为frmTitle的td显示与不显示问题,js代码如下

    <script type="text/javascript">
        function switchSysBar() {
            var ssrc = document.all("frmTitle").style.display;
            if (ssrc == "none") {
                document.all("frmTitle").style.display = "";
            }
            else {
                document.all("frmTitle").style.display = "none"
            }
        } 
    </script>

  这样,完成了。

抱歉!评论已关闭.