Notificaciones Password  Username

Regresar CPortada - Mas que un foro, tu Comunidad.  » Programación & Diseño Web » Programacion WebMaster » HTML
Actualizar esta página JavaScript Confirm
Nombre de Usuario:

Responder al tema
Herramientas Modos de visualización

Old  Administrador
icon2 JavaScript Confirm - el 22/3/2010, 10:22 am

Javascript Confirm

The Javascript confirm function is very similar to the Javascript alert function. A small dialogue box pops up and appears in front of the web page currently in focus. The confirm box is different from the alert box. It supplies the user with a choice; they can either press OK to confirm the popup's message or they can press cancel and not agree to the popup's request.

Confirmation are most often used to confirm an important actions that are taking place on a website. For example, they may be used to confirm an order submission or notify visitors that a link they clicked will take them to another website.

Javascript Confirm Example

Below is an example of how you would use a confirm dialogue box to warn users about something, giving them the option to either continue on or stay put.

HTML & Javascript Code:

<script type="text/javascript">
function confirmation() {
[color=red]var answer = confirm("Leave")[/color]
if (answer){
alert("Bye bye!")
window.location = "";
alert("Thanks for sticking around!")
<input type="button" onclick="confirmation()" value="Leave">

Note the part in red. This is where all the magic happens. We call the confirm function with the message, "Leave Tizag?". Javascript then makes a popup window with two choices and will return a value to our script code depending on which button the user clicks.
If the user clicks OK, a value of 1 is returned. If a user clicks cancel, a value of 0 is returned.. We store this value in answer by setting it equal to the confirm function call.
After answer has stored the value, we then use answer as a conditional statement. If answer is anything but zero, then we will send the user away from If answer is equal to zero, we will keep the user at because they clicked the Cancel button.
In either case, we have a Javascript alert box that appears to inform the user on what is going to happen. It will say, "Bye bye!" if they choose to leave and, "Thanks for sticking around!" if they choose to stay.
In this lesson, we also used the window.location property for the first time. Whatever we set window.location to will be where the browser is redirected to. In this example, we chose We will discuss redirection in greater detail later on.

google_protectAndRun("render_ads.js::google_render_ad", google_handleError, google_render_ad);

Old  Principiante
icon2 Re: JavaScript Confirm - el 14/4/2010, 11:21 am

Hey all.
You can learn more about html at [Tienes que estar registrado y conectado para ver este vínculo]

Comentar con facebook:
 » Temas similares en otros foros
» Problema con salto de línea en JavaScript
» ¿Como adjuntais archivos javascript a vuestro foro?
» ¿Qué es lo que falla?, ¿Cómo defino un TEXTAREA en JAVASCRIPT?
» Modificar código javascript de pop up de amistad.
» Implementar javascript en el portal
Permisos de este foro:
No puedes responder a temas en este foro.

 Los Códigos BB están Activado
 Los Emoticonos están Activado
 Código [IMG] está Activado
 Código HTML está Activado