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

Today is: Friday, 21 November, 2008
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 : Tuesday, 13 June, 2006

Barry is the coolest member of the Innovation Team - not only does he code he's also a rock star (lead vocals and guitarist in the bands BridgeFire and Best of Foo) - what a combination. Barry is extremely interested in the integration of software components and embraces a lot of the current hype around web 2.0 and related concepts as standard.

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

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