Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda