如何将文本文件包含到javascript中 [英] How to include text file into javascript
本文介绍了如何将文本文件包含到javascript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将一些文件从另一个文件加载到javascript中,没有服务器端代码?
Is there any way to load some text from another file into javascript, without server side code?
我正在考虑使用另一个元素将文本保存在某些文件中评论,但我不知道如何用javascript阅读它的源代码。
I was thinking to use another element to hold the text inside some comments, but I don't know how to read it's source code with javascript.
类似的东西:
< script src =myfile.js>< / script>
<脚本> function readMyText(){...}< / script>
在myfile.js中:
/ *一些文字* /
In myfile.js:
/* some text */
推荐答案
不使用ajax或任何服务器代码...抱歉伙伴,但你不能:(
Without using ajax or any server code... sorry mate but you can't :(
这篇关于如何将文本文件包含到javascript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文