不知不覺,我已經工作的有一年半了,第一個公司呆的有三個月,第一個公司一直呆到現在現在,做的系統也不少了。發覺做系統時,還是喜歡用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>
這樣,完成了。