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

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

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 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!