I wrote some JavaScript today which required using a prompt() to request a number. The idea was that you have a table full of numbers, and want to change one. So, you click it, and a prompt() asks for the replacement number.

In Firefox, the prompt is a small modal window which has an ugly title saying something like “The page at http://localhost/…”.

So, I wanted to know is there a way to avoid it. I was hoping that prompt(question,value) had a secret third parameter that set the title.

Unfortunately not, but what I did find was even more annoying. the first hit for javascript prompt is a “tutorial” which is so derisive of the prompt() that I have no idea why the person bothered writing anything at all.

The JavaScript prompt is a relic from the 1990’s

The JavaScript prompt is not very useful and many find it slightly annoying, but hey, this tutorial is here to educate you, so let’s learn how to make that prompt!

You can use a prompt for a wide variety of useless tasks, but below we use it for an exceptionally silly task.

Good job, Tizag – I wonder if all your students (if any can stand the method of teaching) learn to treat JavaScript with the derision that you do. I bet you go to bed chortling at how clever your insults are and how the people that use JavaScript day to day are all idiots.

By the way, you’ve made a few incorrect statements.

The JavaScript prompt is a relic from the 1990’s that you seldom see being used in modern day websites.

Ever heard of Ajax? It involves a lot of user interaction. That sometimes involves requesting a value from the user. The way you do that is prompt(). Now, you /could/ write your own custom version of prompt(), but when it comes down to it, that’s just a prettier version of something that you claim is a relic.

The JavaScript prompt is not very useful

Except for those very common cases where you might require input of a single value.

many find it slightly annoying

[citation needed]

but hey, this tutorial is here to educate you

If education means teaching to sneer, belittle, and misunderstand, then you are correct.

The point of the JavaScript prompt is to gather information from the user so that the information can be used throughout the site to give the visitor a personalized feel.

No! The “point” of prompt() is in its name – it prompts the user for a value. What you do with the value afterwards is of no bearing at all to the function itself.

By the way, your “tutorial” doesn’t even say what the two parameters of prompt() do.


2 Replies to “prompt”

Comments are closed.