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?
CodePudding user response:
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.
CodePudding user response:
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.