Safari 12 Won't Download a PDF blob
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This code is used to download a pdf via blob. It works fine on every browser except Safari 12 for macOS and iOS. Even Safari 11 works. When I run the code the very first time, it works fine, but every time after that it gives me "WebKitBlobResource error 1"
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
javascript macos pdf safari blob
add a comment |
This code is used to download a pdf via blob. It works fine on every browser except Safari 12 for macOS and iOS. Even Safari 11 works. When I run the code the very first time, it works fine, but every time after that it gives me "WebKitBlobResource error 1"
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
javascript macos pdf safari blob
add a comment |
This code is used to download a pdf via blob. It works fine on every browser except Safari 12 for macOS and iOS. Even Safari 11 works. When I run the code the very first time, it works fine, but every time after that it gives me "WebKitBlobResource error 1"
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
javascript macos pdf safari blob
This code is used to download a pdf via blob. It works fine on every browser except Safari 12 for macOS and iOS. Even Safari 11 works. When I run the code the very first time, it works fine, but every time after that it gives me "WebKitBlobResource error 1"
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
function downloadFileFromBlob(fileBlob, fileName) {
if (/bMSIEb|bTridentb/.test($window.navigator.userAgent)) {
$window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
} else {
var fileURL = $window.URL.createObjectURL(fileBlob);
createDownloadElementAndClick(fileURL, fileName);
}
}
function createDownloadElementAndClick(fileURL, fileName) {
var anchorElement = $window.document.createElement('a');
anchorElement.href = fileURL;
anchorElement.target = '_blank';
anchorElement.download = fileName;
var event = $window.document.createEvent("MouseEvents");
event.initEvent("click", true, false);
anchorElement.dispatchEvent(event);
}
javascript macos pdf safari blob
javascript macos pdf safari blob
asked Oct 29 '18 at 15:25
Daniel BaughmanDaniel Baughman
163
163
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It seems that it is the target = "_blank"
that is not working. I have replaced it with _self
, which apparently solved the problem. I found this when I had the same issue.
If someone has a idea on why we cannot use _blank
I would love to hear that.
Given that only blobURIs are concerned by this_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where evenwindow.open(blobURI)
gets blocked.
– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I usea.target = '_self'
, Chrome no longer names the blob download with filename defined in thedownload=""
attribute...
– bmcminn
Feb 5 at 21:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53048734%2fsafari-12-wont-download-a-pdf-blob%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems that it is the target = "_blank"
that is not working. I have replaced it with _self
, which apparently solved the problem. I found this when I had the same issue.
If someone has a idea on why we cannot use _blank
I would love to hear that.
Given that only blobURIs are concerned by this_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where evenwindow.open(blobURI)
gets blocked.
– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I usea.target = '_self'
, Chrome no longer names the blob download with filename defined in thedownload=""
attribute...
– bmcminn
Feb 5 at 21:51
add a comment |
It seems that it is the target = "_blank"
that is not working. I have replaced it with _self
, which apparently solved the problem. I found this when I had the same issue.
If someone has a idea on why we cannot use _blank
I would love to hear that.
Given that only blobURIs are concerned by this_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where evenwindow.open(blobURI)
gets blocked.
– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I usea.target = '_self'
, Chrome no longer names the blob download with filename defined in thedownload=""
attribute...
– bmcminn
Feb 5 at 21:51
add a comment |
It seems that it is the target = "_blank"
that is not working. I have replaced it with _self
, which apparently solved the problem. I found this when I had the same issue.
If someone has a idea on why we cannot use _blank
I would love to hear that.
It seems that it is the target = "_blank"
that is not working. I have replaced it with _self
, which apparently solved the problem. I found this when I had the same issue.
If someone has a idea on why we cannot use _blank
I would love to hear that.
edited Nov 17 '18 at 3:26
jww
54.2k41234516
54.2k41234516
answered Nov 16 '18 at 13:05
Bertrand SteenputBertrand Steenput
213
213
Given that only blobURIs are concerned by this_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where evenwindow.open(blobURI)
gets blocked.
– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I usea.target = '_self'
, Chrome no longer names the blob download with filename defined in thedownload=""
attribute...
– bmcminn
Feb 5 at 21:51
add a comment |
Given that only blobURIs are concerned by this_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where evenwindow.open(blobURI)
gets blocked.
– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I usea.target = '_self'
, Chrome no longer names the blob download with filename defined in thedownload=""
attribute...
– bmcminn
Feb 5 at 21:51
Given that only blobURIs are concerned by this
_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where even window.open(blobURI)
gets blocked.– Kaiido
Nov 17 '18 at 5:04
Given that only blobURIs are concerned by this
_blank
restriction, (dataURI seem to works fine), I'd say it's part of a bigger restriction where even window.open(blobURI)
gets blocked.– Kaiido
Nov 17 '18 at 5:04
Attempting a solution to this as well, problem I have is when I use
a.target = '_self'
, Chrome no longer names the blob download with filename defined in the download=""
attribute...– bmcminn
Feb 5 at 21:51
Attempting a solution to this as well, problem I have is when I use
a.target = '_self'
, Chrome no longer names the blob download with filename defined in the download=""
attribute...– bmcminn
Feb 5 at 21:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53048734%2fsafari-12-wont-download-a-pdf-blob%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown