April 20, 2009

0 Create alert,confirm,prompt boxes in Javascript

want to create an alert box for any user to give out any information while accessing webpage,want to alert him with new messages, or u can have welcome alertbox on page load.

with confirm boxes we can confirm the user age and also can confirm whether the certain actions he wants to perform on web page or not.if he says not then user stays on same page or is redirected to another web page.

prompt box means it is a method of windows object. Prompt uses a text field to enter a value. It also has 'OK' and 'CANCEL' buttons.where else alertbox has only one button

MORE INFO ON ALERT,CONFIRM,PROMPT BOXES IN SCRIPT GIVEN.




<html>
<head>
<script type="javascript">

alert ("Welcome to my Site");

*/ this alert will create an Welcome message for any user on page load */

confirm (" Are u sure");

*/ if user clicks on ok alert button,a confirmation alertbox will ask him whether he sure wants to perform any action and if he clicks cancel or no,the action will not be carried out.*/

prompt ("enter ur name");

*/ suppose if any user clicks on ok confirmation box he or she is asked to enter ur name and age and other details which are asked in the prompt box */

</script>
</body>
</html>

( NOTE: DO NOT FORGET TO CLOSE ALL OPENING AND CLOSING TAGS PROPERLY,OTHERWISE SCRIPT MAY NOT WORK AND WILL SHOW ERROR. )

0 comments:

Post a Comment

Blogger Themes

 
Powered by Blogger