Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda