Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

IE hỗ trợ HTML5 File API


IE9 không hỗ trợ File API

IE10 bắt đầu hỗ trợ File API

Ví dụ của đó là kéo thả. HTML5 cung cấp API Kéo thả (DnD) mang hỗ trợ DnD native cho trình duyệt làm cho việc code dễ dàng hơn.

<!DOCTYPE HTML> <html>    <head>       <style>          #boxA, #boxB { float:left;padding:10px;margin:10px; -moz-user-select:none; }          #boxA { background-color: #6633FF; width:75px; height:75px; }          #boxB { background-color: #FF6699; width:150px; height:150px; }       </style>       <script>          function dragStart(ev) {             ev.dataTransfer.effectAllowed='move';             ev.dataTransfer.setData("Text", ev.target.getAttribute('id'));             ev.dataTransfer.setDragImage(ev.target,0,0);             return true;          }       </script>    </head>    <body>       <center>          <h2>Demo kéo thả HTML5</h2>          <div>Thử kéo hộp tím.</div>          <div id = "boxA" draggable = "true"             ondragstart = "return dragStart(ev)">             <p>Kéo tôi</p>          </div>          <div id = "boxB">Thùng rác</div>       </center>    </body> </html>