prompt

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.

Fail.

2 Comments.

  1. No luck on the prompt unless you want to hack with some DHTML popup or use the VBScript MsgBox in IE.

    Speaking of IE, if you think that the Firefox version of prompt() is a tad ugly, you haven’t seen anything! Check out this post on IE’s epic fail of prompt()

    http://webbugtrack.blogspot.com/2007/10/bug-109-javascript-prompt-in-ie-how-did.html

  2. I hope you replied to this section:

    Found Something Wrong in this Lesson?

    🙂 🙂

    If you want to go with Kyle’s recommendation of the VBScript MsgBox I see that tizag has a tutorial on it aswell!:-)

    http://www.tizag.com/vbscriptTutorial/vbscriptmsgbox.php

    I don’t think its a good idea due to its lack of support for anything but IE

%d bloggers like this: