0

hello can I change the client window object via server node js ? example : window.hello This will be the default variable in the broser window. When I code console.log(hello), the results will appear

1 Answer 1

2

No.

A JavaScript program running on Node.js is a completely different program running in a completely different environment (and probably on a completely different computer).

If you want to set a property of the window object in a webpage, then you need JavaScript running in that webpage to do it. (Usually you would load that JS with a <script> element, but a browser extension could do it too).

If you want to pass data from a Node.js program to a browser-side program then you would need to communicate between them with some kind of message (such as an HTTP response, a Web Socket message, or (if you are using Electron instead of a regular browser) an IPC message.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.