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

143
Views
¿Cómo agregar dos etiquetas <script> en una variable?

Estoy usando una variable para obtener el contenido del archivo de texto, donde el archivo de texto contendrá el elemento HTML

Ejemplo: prueba.txt

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

Para obtener el archivo txt

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

Pero tengo un error en la consola como ingrese la descripción de la imagen aquí

Si verifico tan profundo, mostrará un error en <script async src="https://example.com/js/abc.js"></script> y no muestra la segunda etiqueta <script> .

Incluso probé esto por separado ingrese la descripción de la imagen aquí

En la imagen de arriba puede ver que </script> no se considera una variable.

No sé qué está causando esto. Por favor ayúdame a encontrar una respuesta a este problema...

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

0

Use \ al final de la línea para permitir que la cadena incluya la siguiente línea. Debido a que Javascript no es como PHP, las cadenas no incluyen automáticamente las siguientes líneas.

Por ejemplo: En lugar de...

 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 Report

0

no puede usar más de 1 <script></script> en otra etiqueta de script.

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!