The JavaScript prompt is a relic from the 1990's that you seldom see being used in modern day websites. 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.
Back in the day, you'd often see prompts on personal webpages asking for your name. After you typed in the information, you would be greeted with a page that had a welcome message, such as, "Welcome to My Personal WebPage John Schmieger!" (If your name just so happened to be John Schmieger).
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!
Back in the day, you'd often see prompts on personal webpages asking for your name. After you typed in the information, you would be greeted with a page that had a welcome message, such as, "Welcome to My Personal WebPage John Schmieger!" (If your name just so happened to be John Schmieger).
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!
Simple JavaScript Prompt
You can use a prompt for a wide variety of useless tasks, but below we use it for an exceptionally silly task. Our prompt is used to gather the user's name to be displayed in our alert dialogue box.HTML & JavaScript Code:
<head>
<script type="text/javascript">
<!--
function prompter() {
var reply = prompt("Hey there, good looking stranger! What's your name?", "")
alert ( "Nice to see you around these parts " + reply + "!")
}
//-->
</script>
</head>
<body>
<input type="button" onclick="prompter()" value="Say my name!">
</body>
0 comments
একটি মন্তব্য পোস্ট করুন