You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "coder4589 (via GitHub)" <gi...@apache.org> on 2024/01/06 01:56:49 UTC

Re: [D] Android Web Apps - Save file not working! [cordova]

GitHub user coder4589 edited a discussion: Android Web Apps - Save file not working!

Does anybody here knows how to instruct "Cordova" and\or Android "WebView" to work with the "Save()" function below?

```
<!DOCTYPE html>

<a href='data:text/plain;charset=utf-8,This is a Test' download="Test.txt"> Save - Download </a>

<br><br>

<input type="button" value="Save - Download"  onclick='Save("User Data.txt", "Name: John" + "\r\n\r\n" + "Age: 18" + "\r\n\r\n" + "Country: USA")'>

<script>

function Save(filename, text) {    //_________________________ v1.0 ______________________________

var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);

element.style.display = 'none';
document.body.appendChild(element);

element.click();

document.body.removeChild(element);

}

</script>
```

GitHub link: https://github.com/apache/cordova/discussions/460

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org