You are not Logged in
Would you like to Login or Register

Today is: 10 February 2012
Check this months hot topics

Prompting the user

There are three functions you can call which will force the user to acknowledge them. These are

  • alert()
  • confirm()
  • prompt()

alert()

If you would like to present the user with a notice before allowing them to continue using your web page, you can display an alert.

<a href="javascript:alert('Hello, World!'">See Demo</a>

<script language="javascript">
<!--
  alert("Hello, World!");
-->
</script>

confirm()

To prompt the user with a Yes/No message box you can call confirm, using its return value as the result.

<script language="javascript">
<!--
  var result = confirm("Are you sure?");

  if (result)
    alert("You clicked OK");
  else
    alert("You clicked cancel");
-->
</script>

prompt()

xxx

<script language="javascript">
<!--
  var name = prompt("What is your name?","Mickey Mouse");

  alert(name);
-->
</script>
kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Barrington Haynes Skype
Author : Barrington Haynes
Published : 13 June 2006

I have nothing more to say :-)

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views

More Publications

Custom Validators using Client Side JavaScript
Paul Marshall - 02/11/2007
Garmin and Google Maps
Dave Howard - 19/06/2006
Date and Time Functions
Barrington Haynes - 28/07/2006
Prompting the user
Barrington Haynes - 13/06/2006