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

185
Views
running websocket in google sheet without using HTML code

I find this test for Binance websocket in app script the code in this URL:

running websocket in google sheet

I want to remove code HTML and run websocket without using HTML code.

I want just use:

  

function onOpen(e) {
  SpreadsheetApp.getUi()
    .createMenu('BINANCE')
    .addItem('RUN', 'runwebsocket')
    .addToUi();
  
}

to run websocket

any suggest for the problem .

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

One solution is to embed the html javascript in a blank page

index.html

<!DOCTYPE html>
<meta charset="utf-8" />

<head>
  <script language="javascript" type="text/javascript">
    var wsUri = ("wss://stream.binance.com:9443/ws");
  <? var myparam = param(); ?>
  
  function init()  {
    websocket = new WebSocket(wsUri);
    websocket.onopen = function(evt) { onOpen(evt) };
    websocket.onclose = function(evt) { onClose(evt) };
    websocket.onmessage = function(evt) { onMessage(evt) };
    websocket.onerror = function(evt) { onError(evt) };
    nbr=0;
  }

  function onOpen(evt)  {
    doSend(<?= myparam ?>);
  }

  function onClose(evt)  {
  }

  function onMessage(evt)  {
    google.script.run.getJSON( evt.data );
  }

  function onError(evt)  {
  }

  function doSend(message)  {
    websocket.send(message);
  }

  window.addEventListener("load", init, false);
  window.addEventListener("beforeunload", websocket.close, false);
  
  </script>
</head>

<body></body>

</html>

you can lunch this way

function modal() {
  var html = HtmlService
    .createTemplateFromFile("index")
    .evaluate()
    .setWidth(100)
    .setHeight(50);
  SpreadsheetApp.getUi().showModelessDialog(html, 'web socket');
}

enter image description here

about 4 years ago · Santiago Trujillo 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!