1 Replies - 2316 Views - Last Post: 06 February 2012 - 04:10 PM

#1 sarah_2819  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 11-November 11

Passing variables from node.js file to HTML file - Is this possible?

Posted 06 February 2012 - 03:50 PM

I'm trying to pass this variable:

var answer = answers[Math.floor(Math.random()*answers.length)];

from a node.js file into an HTML file so I can display this variable's answer in a pop-up window using HTML code.

Is this possible, and if so, how would I go about doing this?
Is This A Good Question/Topic? 0
  • +

Replies To: Passing variables from node.js file to HTML file - Is this possible?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: Passing variables from node.js file to HTML file - Is this possible?

Posted 06 February 2012 - 04:10 PM

Sure it's possible, but how exactly you would go about it depends on a few things.

When you say "node.js" file, are we talking about a server-side Node.js application, or is it just a client-side Javascript file named "node.js"? If it's the server-side application, then how exactly is it generating and sending the HTML? (Is it even generating and sending HTML?)

When you say "pop-up window using HTML code", are you talking about creating a pop-up window that contains HTML, or are you trying to have a HTML page create a new pop-up window on some user interaction? If it's the latter, know that HTML can not generate pop-up windows. You must use client-side Javascript for that. (See window.open.)

Please explain in greater detail what you are talking about, so we don't have to keep guessing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1