HTML5是否允许您从Web浏览器中与本地客户端文件进行交互?
不可以,HTML5不允许您直接与本地客户端文件进行交互。您可以为此使用拖放或FileSystemAPI。
示例
让我们看一个使用HTML5在网络浏览器上拖放的示例-
<!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>Drag and drop HTML5 demo</h2>
<div>Try to drag the purple box around.</div>
<div id = "boxA" draggable = "true"
ondragstart = "return dragStart(ev)">
<p>Drag Me</p>
</div>
<div id = "boxB">Dustbin</div>
</center>
</body>
</html>热门推荐
10 开工红包祝福语毕业简短
11 朋友侄子结婚祝福语简短
12 婚礼现场爸妈祝福语简短
13 简短的几句新年祝福语
14 英文关于生日祝福语简短
15 卡片朋友祝福语大全简短
16 给妹妹婚礼祝福语简短
17 小升初送给儿子祝福语简短
18 大哥添孙子简短祝福语