Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
If a button is clicked on active tab, the another tab of the same code button should also be clicked
     <h3>Led 1:</h3>
     <button id="button1" onclick="send1()">Turn ON</button>


and javascript is 
var c = 1;
        function send1() {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (this.readyState == 4 && this.status == 200) {6
                    if (c == 0) {
                        document.getElementById("button1").innerHTML = "Turn ON";
                        document.getElementById("button1").style.backgroundColor ="red";
                        c = 1;
                    }
                    else if (c == 1) {
                        document.getElementById("button1").innerHTML = "Turn OFF";
                        document.getElementById("button1").style.backgroundColor = "green";
                        c = 0;
                    }
                }
            };
            xhttp.open("GET", "https://blynk.cloud/external/api/update?token=PiICxN5NNt2JWKLel25I********&v0=" + c, true);
            xhttp.send();

        }

When the button is clicked it gets a URL which contains the API key and assigns 1 or 0 based on the button click.

So, When I click the button Off in one active tab, another tab button should also be changed to Off.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can explore using Broadcast Channel API which allows basic communication between browsing contexts (such as tabs) on the same origin.

// Current/Active Tab
// Connection to a broadcast channel
const bc = new BroadcastChannel('test_channel');

bc.postMessage('button off');

Then the other tabs can listen to the same channel:

// Other Tabs
const bc = new BroadcastChannel('test_channel');

bc.onmessage = event => {
  if (event.data === 'button off') {
    // do something
  }
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda