html实现下载功能(两种方式)

  • Post author:
  • Post category:其他


```<html>
	<head>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
	</head>
	<body>
      <button id="btn1" style="border = 1px soild red" >下载1</button>
      <button id="btn2">下载2</button>
    </body>
		<script type="text/javascript">
			var $eleBtn1 = $("#btn1");
			$eleBtn1.click(function(){
				window.open("https://codeload.github.com/douban/douban-client/legacy.zip/master");
			});
			//表单下载
			var $eleBtn2 = $("#btn2");
			$eleBtn2.click(function(){
				var $eleForm = $("<form method='get' </form>");
	$eleForm.attr("action","https://codeload.github.com/douban/douban-client/legacy.zip/master");
				$(document.body).append($eleForm);
				$eleForm.submit();
			})
		</script>
	</body>
</html>>



版权声明:本文为weixin_42223701原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。