[英]Download pdf in current page not working?
目前下面的代码工作正常,但我希望将PDF下载到同一页面上,而不是在一个窗口中打开(相同/不同)。 有可能吗?任何帮助将不胜感激
<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>
HTMl:
<a href="example.pdf" download="example" id="hide-link">Download</a>
$(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);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.