Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download file on SamsungBrowser with block auto download (fixes #660) #661

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hudovisk
Copy link

@hudovisk hudovisk commented Jul 11, 2020

SamsungBrowser has a settings enabled by default called "Block automatic downloads" that basically blocks all downloads that are not initiated by user interaction, thus making the call setTimeout(function () { click(a) }, 0) impossible to download a file on this browser, only if the user disables the settings option.

By checking the user agent for SamsungBrowser and calling click(a) instead of setTimeout(function () { click(a) }, 0) the function saveAs work as expected when called from an event initiated by the user. (button click)

Tested on SamsungBrowser 12.0.1.47 with a Smasung S6 SM-G920I.

Code used to test:

<html>
    <head>
        <script src="FileSaver.min.js"></script>
    </head>

    <body>
        <button onclick="download()">download</button>
        <script>
            var testCsv = "this,is,a,row\nthis,is,another,row";
            function download() {
                var blob = new Blob([testCsv], { type: 'text/csv;charset=utf-8;' });
                saveAs(blob, "test.csv")
            }
        </script>
    </body>
</html>

Fixes #660

@lattam
Copy link

lattam commented Oct 30, 2020

Pardon my question, but what is the purpose of the setTimeout with 0 milliseconds in the original code anyway?

@MoeHamdan
Copy link

MoeHamdan commented May 3, 2023

Hello any update on this? will this be released yet? Also does this really fix it? I guess not I have tried something similar locally and same result it fails to download while block automatic downloads is on.

@MoeHamdan
Copy link

This needs to change to use window.open which works with Samsung Browser.. window.open(blob) though the file name will be lost but it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail to download on Samsung Internet Browser
3 participants