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

179
Views
Execute script retrieved as a string

I need to find the most correct way to display and execute an advertising banner inside a div with this format:

<div id="1111-1"><script src="//ads.website.com/s/gen.js?type=2"></script><script src="//ads.website.com/s/requestform.js?siteId=1111&formatId=2"></script></div>

I have prepared a div with:

<div class="myclass" id="myid"></div>

but I can't execute anything. I've tried:

 let element = document.getElementById('adsmoneytizer').innerHTML = app.forum.attribute('adscode') || "";
    eval(element);

where app.forum.attribute return the string "<div id="1111-1"><script src="//ads.website.com/s/gen.js?type=2"></script><script src="//ads.website.com/s/requestform.js?siteId=1111&formatId=2"></script></div>"

How can I display and execute this code?

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

0

You should be appending element to the body for the script to execute:

let element = document.createElement('div')
element.innerHTML = app.forum.attribute('adscode') || "";
document.body.appendChild(element)
about 4 years ago · Juan Pablo Isaza Report

0

you should use eval() instead to make it works

 $(this.node).find('script').each(function(index, element) {
        eval(element.innerHTML);
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!