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

193
Views
Si se hace clic en un botón en la pestaña activa, también se debe hacer clic en la otra pestaña del mismo botón de código
 <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(); }

Cuando se hace clic en el botón, obtiene una URL que contiene la clave API y asigna 1 o 0 según el clic del botón.

Entonces, cuando hago clic en el botón Desactivado en una pestaña activa, otro botón de pestaña también debe cambiarse a Desactivado.

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

0

Puede explorar utilizando la API de canal de difusión que permite la comunicación básica entre contextos de navegación (como pestañas) en el mismo origen.

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

Luego, las otras pestañas pueden escuchar el mismo canal:

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