htm5 浏览器文件拖拽到本地

<link href="css/default.css" rel="stylesheet" type="text/css" />
<style>
            .dragout {
              cursor: move;
              background: #ddd;
              padding: 6px;
              margin: 10px;
              border: 1px solid #666;
            }
          </style>
<div class="example">
              Drag each of these files onto your desktop:
              <a href="http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en/us/intl/en/landing/chrome/cadie/glasses.pdf" class="dragout" data-downloadurl="application/pdf:Chrome3DGlasses.pdf:http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en/us/intl/en/landing/chrome/cadie/glasses.pdf">.pdf file</a>
              <a href="src/star.mp3" class="dragout" data-downloadurl="audio/mpeg:star.mp3:http://slides.html5rocks.com/src/star.mp3">.mp3 file</a>
            </div>
            <p class="center" style="font-size:90%">( this feature is only available in Google Chrome )</p>
            <script defer>
              (function() {
                var files = document.querySelectorAll('.dragout');
                for (var i = 0, file; file = files[i]; ++i) {
                  file.setAttribute('draggable', 'true'); // Don't really need, but good practice.
                  file.addEventListener('dragstart', function(evt) {
                    evt.dataTransfer.setData('DownloadURL', this.getAttribute('data-downloadurl'));
                  }, false);
                }
              })();
            </script>
          </section>
        </div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值