js download file function

method one:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head runat="server">
<title>File Download</title>
</head>
<!DOCTYPE html>  
<
<body>  
<script>
function downLoad(){
    var elemIF = document.createElement("iframe");   
    elemIF.src = http://down.360safe.com/360safe_cq.exe;  
    elemIF.style.display = "none";   
    document.body.appendChild(elemIF);

}
</script>

<a href="#" onClick="downLoad()">Click to download</a>
</body>  
</html>

Method Two:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head runat="server">
<title>File Download</title>
</head>
<!DOCTYPE html>  
<
<body>  
<script>
function downLoad(){
    window.location.href=http://down.360safe.com/360safe_cq.exe;
}
</script>

<a href="#" onClick="downLoad()">Click to download</a>
</body>  
</html>



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325356959&siteId=291194637