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

142
Views
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 answers
Answer question

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 Report

0

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

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!