JavaScript - Botones de confirm

 
Vista:

Botones de confirm

Publicado por Alejandro Perez (1 intervención) el 04/05/2011 22:33:50
Buen dia, tengo una duda cuando uno hace uso de la instruccion confirm, la respuesta aparece en 2 botones ACEPTAR Y CANCELAR, es posible cambiar el texto de estos botones a SI y NO,
y tambien sera posible cambiar el mensaje que aparece en la cabecera del mensaje, gracias por sus respuestas
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Botones de confirm

Publicado por xve (2100 intervenciones) el 08/05/2011 22:19:28
Hola Alejandro, por lo visto, no se pueden cambiar dichos botones, pero navegando por la red, he encontrado este codigo, que te muestra tu pregunta, con los botones como tu quieres. No es una ventana, sino que es una capa.

Espero que te sirva

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
 
<style type="text/css">
#confirmBox {
	width:10em;
	height:5em;
	position:absolute;
	z-index:1;
	visibility:hidden;
	background:blue;
	color:white;
	border:6px double white;
	text-align:center;
}
</style>
 
<script type="text/javascript">
var answerFunction;
 
function myConfirm(text,button1,button2,answerFunc)
{
	var box = document.getElementById("confirmBox");
	box.getElementsByTagName("p")[0].firstChild.nodeValue = text;
	var button = box.getElementsByTagName("input");
	button[0].value=button1;
	button[1].value=button2;
	answerFunction = answerFunc;
	box.style.visibility="visible";
}
 
function answer(response)
{
	document.getElementById("confirmBox").style.visibility="hidden";
	answerFunction(response);
}
 
function tester(button)
	{
	myConfirm("Say Aye or Nay!","Aye","Nay",
	function(answer)
	{
		button.value="Last answer was: "+(answer?"Aye":"Nay");
	});
}
</script>
 
</head>
<body>
<div id="confirmBox">
	<p>Continue?</p>
	<p><input type="button" onclick="answer(true)" value="Ok">
	<input type="button" onclick="answer(false)" value="Cancel"></p>
</div>
 
<input type="button" value="Answer me!" onclick="tester(this)">
</body>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar