5

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

1 Answer 1

3

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?

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

4 Comments

@Chirstian Schulze Yeah i'm trying to showing a popup. But i seen in cloud9ide open source code in that they used " window.open() " method. So , just i tried the same thing in my code whether it'll work or not.. Anyway thanks Christian Schulze for quick reply. :)
@PradeepRaj Could you provide a link to the exact file your’re talking about?
@AlexMills What exactly should this do? There is no prompt function in node. And per se you can’t show a popup via node in the user’s browser (if you’re not using sockets and stuff) or working with a module providing cli “ui”.
I was mistaken, and deleted my comment

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.