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

273
Vistas
How to use document.write() with a file instead of just text?

I am using socket.io to create a party game similar to cards against humanity. I am just wondering how I can keep the players name and score etc without having to send all the data to a new page when new games begin. I was thinking to just change the body of the html but stay on the same page so the javascript doesnt reset and I can still access all the players information.

I came across using document.write() however this appears to only accept a string parameter. Is there a way to do something like this document.write(game.html).

Any ideas on how to go about this, maybe a better way to pass information between javascript files without having to post the data each time a new page is loaded? I have tried sending the data with post however it makes it far more difficult to keep everything consistent.

P.S This is the first time I have properly made anything with node.js, socket.io, javascript etc. So I could be asking a stupid question.

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

0

Once you get socket.io data from an event listener, you can use querySelector() or any other DOM manipulation method to show the data in the DOM. Something like this?

HTML

<div id="panel"></div>

JS

const socket = io("ws://localhost:3000" )
const panel = document.querySelector("#panel")
// receive a message from the server
socket.on( "hello", (arg) => {
    panel.innerText = arg
});
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