日期:2014-05-16  浏览次数:20303 次

JavaScript实现点击按钮下载

    <script type="text/javascript"">
           //第一种
            function downFile() {
                var url = "http://localhost/tst/ya.rar";
                location.href = url;
            }
         //第二种
          function downFile() {
                var url = "http://localhost/tst/ya.rar";
                window.open(url);
            }
        </script>
        <a href="http://localhost/tst/ya.rar">下载</a>
        <input type="button" value="下载" onclick="downFile()">