“File Unduh JavaScript” Kode Jawaban

cara mengunduh file dalam python

import urllib.request

print('Beginning file download with urllib2...')

url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
urllib.request.urlretrieve(url, '/Users/scott/Downloads/cat.jpg')
Ali0gamer

Unduh File JavaScript

function download(link) {
  var element = document.createElement('a');
  element.setAttribute('href', link);

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

  element.click();

  document.body.removeChild(element);
}
Defeated Dotterel

File Unduh JavaScript

let data = JSON.stringify([{email: "[email protected]", name: "test"}, {email: "[email protected]", name: "anothertest"}]);

let type = "application/json", name = "testfile.json";
downloader(data, type, name)

function downloader(data, type, name) {
	let blob = new Blob([data], {type});
	let url = window.URL.createObjectURL(blob);
	downloadURI(url, name);
	window.URL.revokeObjectURL(url);
}

function downloadURI(uri, name) {
    let link = document.createElement("a");
    link.download = name;
    link.href = uri;
    link.click();
}
 Run code snippet
Frail Fox

JS Unduh File dari WebServer

<iframe id="download_iframe" style="display:none;"></iframe>
<script>
	document.getElementById('download_iframe').src = "/example/example.txt";
</script>

Defiant Duck

File Unduh JavaScript

$('a#someID').attr({target: '_blank', 
                    href  : 'http://localhost/directory/file.pdf'});
JDog

Jawaban yang mirip dengan “File Unduh JavaScript”

Pertanyaan yang mirip dengan “File Unduh JavaScript”

Lebih banyak jawaban terkait untuk “File Unduh JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya