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

151
Visualizações
How to add two <script> tag in one variable?

I am using one variable to fetch the text file content, where the text file will contain the HTML element

Example: test.txt

<main>
  <div> Example </div>
  <script async src="https://example.com/js/abc.js"></script>
  <script>(some inner text);</script><br>
</main>

To fetch the txt file

var contents = '<?php print file_get_contents('abc/test.txt'); ?>'; document.getElementById('replace_contents').innerHTML = htmlCode;

But I got an error in the console like enter image description here

If i check that deep it will show an error in <script async src="https://example.com/js/abc.js"></script> and it does not show the second <script> tag..

Even i tried this separate enter image description here

In the above picture you can see </script> is not considered as a variable.

I don't know what is causing this. Please help me find an answer to this problem...

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Use \ at the end of the line to allow the string to include the following line. Because Javascript is not like PHP, strings don't automatically include next lines.

For example : Instead of ...

var lines = 'here is the first line
but the second line is not included'; // Error

You can write...

var lines = 'here is the first line\
and now the second line is included'; // Correct

Or use the + operator

var lines = 'here is the first line' +
'and I add the second line'; // Correct

about 4 years ago · Juan Pablo Isaza Relatório

0

you can't use more than 1 <script></script> in another script tag.

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