當(dāng)你在做一個(gè)仿windows程序的頂部菜單框架的時(shí)候,在asp.net中你可能會(huì)使用兩個(gè)frame,一個(gè)frame在上面用來(lái)放菜單一個(gè)frame在下面用來(lái)方菜單點(diǎn)擊后打開的頁(yè)面.頁(yè)面實(shí)現(xiàn)很簡(jiǎn)單,
單運(yùn)行的時(shí)候你就發(fā)現(xiàn)放菜單的那個(gè)frame將菜單的下列菜單在擋住根本伸不到下面的frame中.解決被擋住的問(wèn)題是不能使用frame,做法是在一個(gè)單獨(dú)的asp.net頁(yè)面中放一個(gè)menu 和一個(gè)iframe,嗯,至此下拉菜單不會(huì)被擋住,單又有一個(gè)新問(wèn)題出來(lái)了,那就是iframe的高度問(wèn)題,如果強(qiáng)制寫死它的高度,那根本是不可接受的.如果解決?解決的辦法就是使用javascript 在body的onload和onsized事件中對(duì)iframe的高度進(jìn)行控制.下面代碼解決上述的問(wèn)題. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<html> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無(wú)標(biāo)題頁(yè)</title>
<script language="javascript" type="text/javascript">
function aaaaa() {
document.getElementById('f1').height=document.body.clientHeight-80; }
</script>
</head> <body onload="aaaaa()" onresize="aaaaa()" scroll="no" style="margin: 0"> <form id="form1" runat="server"> <table> <tr> <td height="80"> <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" BackColor="#E3EAEB" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#666666" StaticSubMenuIndent="10px"> <StaticSelectedStyle BackColor="#1C5E55" /> <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <DynamicHoverStyle BackColor="#666666" ForeColor="White" /> <DynamicMenuStyle BackColor="#E3EAEB" /> <DynamicSelectedStyle BackColor="#1C5E55" /> <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <StaticHoverStyle BackColor="#666666" ForeColor="White" /> <Items> <asp:MenuItem Text="新建項(xiàng)1" Value="新建項(xiàng)1"> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> </asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)" Value="新建項(xiàng)"></asp:MenuItem> </asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)2" Value="新建項(xiàng)2"></asp:MenuItem> <asp:MenuItem Text="新建項(xiàng)3" Value="新建項(xiàng)3"></asp:MenuItem> </Items> </asp:Menu> </td> </tr> </table> <iframe id="f1" scrolling="auto" width="100%" height="200" src="HTMLPage5.htm"></iframe> </iframe> </form> </body> </html>
|