본문 바로가기

HTML5/Download Links

HTML5 Download Links

HTML5 링크를 통한 다운로드 예


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>링크를 이용한 다운로드 기능 테스트</title>
<script type="text/javascript">

function test() {
	alert('test');
}

function test9() {
	var a5 = document.querySelector('#a5');
	a5.href='sample.zip';
	a5.download='test5.zip';
	a5.click();
}

function test10() {
	var a = document.createElement("a");
    document.body.appendChild(a);
    a.style = "display: none";
    a.href = 'sample.zip';
    a.download = 'test10.zip';
    a.click();
}

</script>
</head>
<body><p>

<a href="binaryClient.html">링크 1</a> <p>
<a href="binaryClient.html" download>링크 2</a> <p>
<a href="binaryClient.html" download="test.zip">링크 3</a> <p>
<a href="binaryClient.html" download="client.html">링크 4</a> <p>

<a id='a5'>링크 5</a> <p>
<a href='#'>링크 6</a> <p>
<a id="a7" href='#'>링크 7</a> <p>
<a id="a8" href='#' onclick='test()'>링크 8</a> <p>
<a id="a9" href='#' onclick='test9()'>링크 9</a> <p>
<a id="a10" href='#' onclick='test10()'>링크 10</a> <p>

</body>
</html>