Javascript 在当前页面中下载pdf不起作用?
目前,下面的代码运行良好,但我希望PDF下载在同一页上,而不是在窗口中打开(相同/不同)。 有可能吗?如果有任何帮助,我们将不胜感激Javascript 在当前页面中下载pdf不起作用?,javascript,jquery,html,anchor,href,Javascript,Jquery,Html,Anchor,Href,目前,下面的代码运行良好,但我希望PDF下载在同一页上,而不是在窗口中打开(相同/不同)。 有可能吗?如果有任何帮助,我们将不胜感激 <script> $(document).ready(function () { setTimeout(function () { $('a[href]#hide-link').each(function () { var href = this.href; $(t
<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>
$(文档).ready(函数(){
setTimeout(函数(){
$('a[href]#隐藏链接')。每个(函数(){
var href=this.href;
$(this).removeAttr('href').css('cursor','pointer')。单击(函数(){
if(href.toLowerCase().indexOf(“#”)>=0{
}否则{
window.open(href,'u self');
}
});
});
}, 500);
});
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);
});