模态窗口,解决下载问题

代码如下:

    <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,这样又回到最初状态,查询也没问题了

转载于:https://www.cnblogs.com/jery0125/archive/2013/02/26/2933299.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值