博客园  :: 首页  :: 联系 :: 管理

首页弹出公告,自适应大小

Posted on 2008-10-24 13:04  sunrack  阅读(285)  评论(0)    收藏  举报

 

 

首页的 Page_load

 protected void Page_Load(object sender, EventArgs e)
        {
                        List
<Article> curPopupNoticeList = ArticleData.GetPopupNotice("中心公告");

            
int top = 0;
            
int left = 0;

            
int height = 10;
            
int width = 360;

            
int stepSize = 50;

            
foreach (Article popupNotice in curPopupNoticeList)
            {
                top 
+= stepSize;
                left 
+= stepSize;

                
string script =
                    
"<script   language=javascript>window.open('PopupNotice.aspx?ArticleID=";

                script 
+= popupNotice.ArticleID + "', ";

                script 
+= "'" + "title" + popupNotice.ArticleID + "', '";

                script 
+= "height=" + height + ",";
                script 
+= "width=" + width + ",";
                script 
+= "top=" + top  + ",";
                script 
+= "left=" + left + ",";

                script 
+= "toolbar=no,   menubar=no,   scrollbars=no,   resizable=no,location=no,   status=no')</script>";

                Response.Write(script);
            }
        }

 

 

弹出页面的脚本

 

 

<head runat="server">
    
<title></title>

    
<script>
        function window.onload()
        {
            
//var obj = document.getElementById("DivNoticeFrame");
            var obj = document.documentElement;

            window.resizeTo(
360, obj.scrollHeight + 40);
        } 
    
</script>

</head>