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

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

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