代码之家  ›  专栏  ›  技术社区  ›  gideon

在internet explorer中创建url时,jquery after()无法正常工作

  •  0
  • gideon  · 技术社区  · 15 年前

    所以我有一个函数,通过asp.net异步导出一些数据,并在页面上显示一个URL以下载导出的文件,它在chrome中运行得非常好。但在internet explorer中,它显示链接,但链接不能单击,它只是以纯文本呈现!

    Export.aspx返回的数据包含导出文件的URL(记住它在chrome中工作得非常好)

    function doExport(oper) {
                    var pass = prompt("Please enter the Admin password", "none");
                    if (hex_md5(pass) == "592e19c40272fcc615079c346a18d140") {
                        $("#btnExportStat").attr('disabled', 'disabled');
                        $("#btnExportView").attr('disabled', 'disabled');
                        $("#btnAfter").after("<p id='loading'>Please wait...<img src='images/loading.gif' /></p>");
                        jQuery.post("Export.aspx", { "type": oper }, function (data) {
                            $('#loading').remove();
                            if (data.toString() == "error") {
                                $('#btnAfter').after("<b>There was an error</b>");
                            } else {
                                var d = new Date();
                                var curr_hour = d.getHours();
                                var curr_min = d.getMinutes();
                                var sec = d.getSeconds();
              ========>>>//$('#btnAfter').after("<a href='" + data + "'>" + "Click here to Download File(" + curr_hour + ":" + curr_min + ":" + sec + ")</p>");
                                $("#btnExportStat").attr('disabled', '');
                                $("#btnExportView").attr('disabled', '');
                            }
                        });
                    } else {
                    alert("Incorrect password");
                    }
                }
    
    1 回复  |  直到 11 年前
        1
  •  2
  •   Pointy    15 年前

    你从 <a> 但以 </p> ...

    称我为守旧派,但我通常会添加不同的标记:

    $('#btnAfter').after($("<a/>")
      .attr('href', data)
      .text("Click here to Download File(" + curr_hour + ":" + curr_min + ":" + sec + ")")
    );