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.
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 the textarea
tag has an opening and closing tag.
Use the code below:
document.querySelector("textarea").innerHTML = "Textarea!";
EDIT: Editing the text on a different webpage is a security risk.
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?
check appendchild and innerhtml
So is it not possible to get data from locally stored files? I want to be able to run the webpage offline.
If you want to run it offline, you can make your website a PWA.
That’s why it’s stored locally – my device lets me run HTML files stored on my device.
What I’m asking is, can you set the value (in your example “Textarea!”) to be the inner HTML of a
Not that I know of. It might be a security risk.
OK, well, thanks for helping anyways.