是否可以设置a< textarea>标签是HTML文件的源代码?
我想知道是否可以设置a< textarea>标签要设置为网页的HTML。
我试图将值设置为等于本地文件的HTML“ ./file.html”。
document.getElementById("textareaTag").value = ;
由于我是JavaScript的新手,因此我没有解决方案,即使可能有一个。谁能帮我吗?
注意:有些人四处挖掘会使使用window.open()命令完成此操作。它可以工作吗?如果是这样,怎么样?
I want to know if it is possible to set the value property of a <textarea> tag to be set to the HTML of a webpage.
I'm trying to set the value to be equal to the HTML of the local file "./file.html".
document.getElementById("textareaTag").value = ;
Since I'm new to JavaScript, I don't have a solution, even though there probably is one. Can anyone help me?
NOTE: Some digging around makes it look like it might be possible to accomplish this with a window.open() command. Would it work? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过此方法将HTML文件放入JS变量:
,然后将变量放入TextAarea中。
尽管在Textarea中,您无法显示HTML标签,并且需要像Ckeditor这样的Wysiwyg富文本编辑器。
You can place an HTML file into a JS variable by this method:
And then put variable into textarea.
Although in textarea you can't show html tags and you need a WYSIWYG rich text editor like CKEditor.
我不确定我是否理解您的问题,但我会尽力回答。
您可以使用
使用以下代码:
编辑:在不同网页上编辑文本存在安全风险。
I'm not sure if I understand your question, but I'll try my best to answer.
You can set the text inside of a
<textarea>
using the.innerHTML
property, as thetextarea
tag has an opening and closing tag.Use the code below:
EDIT: Editing the text on a different webpage is a security risk.