zoukankan      html  css  js  c++  java
  • 模态窗口,解决下载问题

    代码如下:

        <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="100px; height:42px;" class="td13">年  级</td>
                       <td style="150px; height:42px;" class="td13">班级名称</td>
                       <td style="150px; height:42px;" class="td13">课程名称</td>
                       <td style="100px; height:42px;" class="td13">上传教师</td>
                       <td style="100px; height:42px;" class="td13">文件类型</td>
                       <td style="100px; height:42px;" class="td14">下载</td>
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr align="center" valign="middle" style="background-color:White;">
                       <td style="100px; height:32px;" class="td15"><%# Eval("SYear") %>_<%# Eval("STerm") %></td>
                       <td style="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="150px; height:32px;" class="td15"><%# Eval("Course.CourseName") %></td>
                       <td style="100px; height:32px;" class="td15"><%# Eval("Teacher.TeaName") %></td>
                       <td style="100px; height:32px;" class="td15"><%# Eval("FileManager_Class.ClassName")%></td>
                       <td style="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,这样又回到最初状态,查询也没问题了

  • 相关阅读:
    arduino链接GY521(MPU6050)模块
    I2C Python Library ITG3205 API
    [翻译]AxureInteractive Prototypes原型设计工具Axure学习第2.3节
    [Java]XML数据的请求和DOM技术解析
    [Linux]VI相关操作
    mysql数据库连接错误问题
    关于管理单元初始化失败的解决方法
    彻底明白Java的IO系统(网上找的,还没看,先放这)
    一个关于C++ Inline关键字的引发的一个错误
    orcale 中日期类型相加的处理
  • 原文地址:https://www.cnblogs.com/jery0125/p/2933299.html
Copyright © 2011-2022 走看看