在当前页面下载pdf不起作用?

时间:2017-07-12 09:25:33

标签: javascript jquery html5 anchor href

目前下面的代码工作正常但我希望PDF可以在同一页面上下载而不是在窗口中打开(相同/不同)。 是否有可能?感谢任何帮助

@CrossOrigin(origins = "http://localhost:5555")

HTMl:

<script>
$(document).ready(function () {
    setTimeout(function () {

          $('a[href]#hide-link').each(function () {
              var href = this.href;

              $(this).removeAttr('href').css('cursor', 'pointer').click(function () {
                  if (href.toLowerCase().indexOf("#") >= 0) {

                  } else {
                      window.open(href, '_self');


                  }
              });
          });

    }, 500);
});
</script>

1 个答案:

答案 0 :(得分:0)

$(document).ready(function () {
            setTimeout(function () {

                $('a[href]#hide-link').each(function () {
                    var href = this.href;
                    $(this).removeAttr('href').css('cursor', 'pointer').click(function () {
                        if (href.toLowerCase().indexOf("#") >= 0) {

                        } else {
                            window.location = href;
                        }
                    });
                });

            }, 500);
        });