简体   繁体   中英

How to show popup message using Node.JS

I wanna show some popup message from server side javascript(Node.JS) code.

exports.ShowPopup = function(req, res){ window.alert("Pradeep"); };

This was i tried. But while redirecting to this path i'm getting the error like

" window is not defined "

So can u please help me on this.Thanks in Advance.

With regards

Pradeep Raj. K

This is not possible. You cannot control the users browser with server side executed code.

I think you misunderstood NodeJS. NodeJS is a binary that runs javascript as server side code. It works just as any other scripting language on a server like Python or such.

You tried to use the window object, which is exclusive to the (or most) browsers API and does not exist in the regular Node environment. Also you don't have any GUI, so you won't be able to accomplish what you are trying. Just use regular front end javascript for this.

PS: I assume you meant showing a popup in the browser, right?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM