Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
Is it possible to set the value property of a <textarea> tag to be the source code of an html file?

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?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can place an HTML file into a JS variable by this method:

Load page content to variable

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.

about 4 years ago · Juan Pablo Isaza Report

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!