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

107
Vistas
Insert html tag and script tag dynamically from javascript

Basically, I am trying to add dynamically some html and script from javascript. But the script which is being appended from javascript is not invoked or called during rendering of base html.

<html>
<head>
</head>
<body>

<div id="container" style="width:100vw;height:100vh;position:relative;"></div>

<script type="text/javascript">
! function() {
    var ht = '<script src=\'https:\/\/www.googletagservices.com\/dcm\/dcmads.js\'><\/script>'
    var target= document.getElementById("container");
    var newScript = document.createElement("div");
    newScript.innerHTML = ht
    target.appendChild(newScript);   
}();

</script>

</body>
</html>

I have tried innerHtml and appendChild both seem to be not working. I want to add a complete HTML tag(including script which cannot be changed) in the ht variable. How we can add any HTML script from javascript and render it?

about 4 years ago · Juan Pablo Isaza
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