模态窗口,解决下载问题

代码如下:

    <base id="goDownload" target="_self" />
    <script type="text/javascript">
        function showMsg()
        {
           var downloadBase=document.getElementById("goDownload");
           var downloadBox=document.getElementById("download");
           download.src=document.URL;
           downloadBase.target="download";
           setTimeout("CancelMsg()",1000);
        }
        function CancelMsg()
        {
           var downloadBase=document.getElementById("goDownload");
           downloadBase.target="_self";
        } 
    </script>

    <table width="700px" border="0" cellpadding="0" cellspacing="0" align="center" style=" margin-top:10px;">
        <asp:Repeater ID="RepeaterFileManager" runat="server" OnItemCommand="RepeaterFileManager_OnItemCommand">
            <HeaderTemplate>
                <tr align="center" valign="middle" style="background-color:#A4E3F4;">
                   <td style="width:100px; height:42px;" class="td13">年  级</td>
                   <td style="width:150px; height:42px;" class="td13">班级名称</td>
                   <td style="width:150px; height:42px;" class="td13">课程名称</td>
                   <td style="width:100px; height:42px;" class="td13">上传教师</td>
                   <td style="width:100px; height:42px;" class="td13">文件类型</td>
                   <td style="width:100px; height:42px;" class="td14">下载</td>
                </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr align="center" valign="middle" style="background-color:White;">
                   <td style="width:100px; height:32px;" class="td15"><%# Eval("SYear") %>_<%# Eval("STerm") %></td>
                   <td style="width:150px; height:32px;" class="td15">
                      <%# Convert.ToInt32(Eval("FileManagerClassID")) == 1 ? Convert.ToInt32(Eval("ClassID")) == -1 ? Eval("Course.Vocational.VocationalName") : Eval("ClassInfo.ClassName") : "&nbsp;"%>
                   </td>
                   <td style="width:150px; height:32px;" class="td15"><%# Eval("Course.CourseName") %></td>
                   <td style="width:100px; height:32px;" class="td15"><%# Eval("Teacher.TeaName") %></td>
                   <td style="width:100px; height:32px;" class="td15"><%# Eval("FileManager_Class.ClassName")%></td>
                   <td style="width:100px; height:32px;" class="td16">
                     <asp:LinkButton ID="linkBtDownLoad" runat="server" CommandArgument='<%# Eval("Id") %>' 
                         CommandName="goDown" OnClientClick="showMsg()">下载</asp:LinkButton>
                   </td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>
    </table>

    <iframe id="download" src="FileManager.aspx" name="download" height="0" width="0"></iframe>

 

思路:
遇到这个问题的朋友知道:
问题一:<base target="_bank" /> 下载没问题,可是会打开新窗口,用户体验不好
问题二:<base target="_self" /> 下载框,弹不出来
问题三:<base id="goDownload" target="_self" /> <iframe id="download" src="FileManager.aspx" name="download" height="0" width="0"></iframe>
        下载是没问题了,但是下载后分页查询的效果没了、、、
最终解决方案:
如上代码,加上两个方法,设置延迟函数。需要下载的时候,把<base id="goDownload" target="_self" />改动指向iframe(id为download)
这样就可以弹出下载框了,在一秒后又设成_self,这样又回到最初状态,查询也没问题了

posted @ 2013-02-26 11:58  ~夜~  阅读(405)  评论(0编辑  收藏  举报