马黑PHP整站系统

JS打开本地文本文件

位置: 首页 > 代码集锦[ 发布时间: 2024.1.21  作者: 马黑  阅读: 143 ]

【附】代码

<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 发布: 这个显示框可拖动变宽窄大小。。。灵活。。。

Copyright © 2023 All Right Reserved 马黑PHP文章管理整站系统v1.8
联系我们: gxblk@163.com