JS打开本地文本文件
【附】代码
<style>
.ma { width: 100%; display: flex;flex-direction: column; gap: 10px; }
.ma > p:nth-of-type(2) {text-align: center; }
#txtElm { width: 800px; height: 400px; }
</style>
<div class="ma">
<p><input type="file" id="sFile" accept=".txt, .bat, .php"></p>
<p><textarea id="txtElm"></textarea></p>
</div>
<script>
sFile.onchange = function() {
var reader = new FileReader();
reader.readAsText(this.files[0]);
reader.onload = function() {
txtElm.value = this.result;
};
};
</script>
前一篇: 烟消云散:CSS文本特效演示
下一篇: 用CSS+HTML画一棵儿童画的树
发表评论:
评论列表 [1条]
#1 | 悄然 于 2024-1-22 08:51 发布: 这个显示框可拖动变宽窄大小。。。灵活。。。
