/    Sign up×
Community /Pin to ProfileBookmark

About downloading pdf files with jquery/Javascript

Hello,
I am downloading PDF file with below code. It works pretty well
It also shows the downloading icon next to the button. Buddha works fine.

“`
function pdf_dow(butonid, url_link, dosya_adi) {

// Code showing the downloading icon next to the button while downloading the file
var setLoading = function () {
var search = $(“#” + butonid + “”);
if (!search.data(‘normal-text’)) {
search.data(‘normal-text’, search.html());
}
search.html(search.data(‘loading-text’));
};

var clearLoading = function () {
var search = $(“#” + butonid + “”);
search.html(search.data(‘normal-text’));
};
setLoading();

// File download code
fetch(url_link)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement(‘a’);
//a.style.display = ‘none’;
a.href = url;
// istediğiniz dosya adı
a.download = dosya_adi + “.pdf”;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
clearLoading();
})
.catch(() => alert(‘PDF Dosya indirmede bir hata oluştunLütfen tekrar deneyinnSorun devam ederse yöneticiye bildirin!’));

}
“`

Problem downloading pdf on phone

When the PDF file is downloaded with the code above, the phone screen below shows an icon on the top of the phone as shown in the picture.
This icon may be overlooked by the user, causing them to think that the PDF file has not been downloaded.
[url=https://www.hizliresim.com/8f7f5j8][img]https://i.hizliresim.com/8f7f5j8.png[/img][/url]

The phone screen below in the notification panel looks as shown in the picture
[url=https://www.hizliresim.com/ace5t01][img]https://i.hizliresim.com/ace5t01.png[/img][/url]

I want the PDF file to be downloaded as shown in the phone screenshot below
How to make a change in the code to download the PDF file as shown in the image below
[url=https://www.hizliresim.com/q7rjd42][img]https://i.hizliresim.com/q7rjd42.png[/img][/url]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@pipahahaAug 12.2021 — that was amazing

[word counter](https://wordcounter.tools)
×

Success!

Help @gecekule spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...