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

90
Vistas
Toggle Visibility of an Uncontrollable Element in React

I have Hubspot chat script embedded in the index.html file of my React App using the <script/> tag for user communication.

Now, when a button is clicked I want the hubspot container to be hidden and then when another button is clicked I want it to be displayed again.

I do not have control over the behaviour of the chat icon because it was added to the page via a <script/> tag.

But after some digging I was able to get the id of the element so here is how I've tried toggling the visibility of the chat but it's not working for me.

const toggleHubspotContainer = (turnOn) => {
        let hubSpotContainer = document.getElementById("hubspot-messages-iframe-container");
        if (turnOn) {
            hubSpotContainer.style.display = 'block';
            return;
        }
        hubSpotContainer.style.display = 'none'; //The chat icon is not hiding even after this
    }

Please note that the hubspot script was added in the index.html file like this

<script type="text/javascript" id="hs-script-loader" async defer src="//js-eu1.hs-scripts.com/adadadad.js"></script>

Is there a way to do this properly?

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this, consider your script is in header

function hideHb() {
  var head = document.getElementsByTagName('head').item(0);
  var js = document.getElementById("hs-script-loader");
  head.parentNode.removeChild(js);
}
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