IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Ajouter une image dans la boite "confirm"


Sujet :

JavaScript

  1. #1
    Membre à l'essai
    Homme Profil pro
    Webmaster
    Inscrit en
    Avril 2013
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2013
    Messages : 14
    Points : 11
    Points
    11
    Par défaut Ajouter une image dans la boite "confirm"
    je creer une boite confirm a mon site avec comme question: souhaitez vous continuer ?

    Est il possible d'ajouter une image dans une boite "confirm" par exemple celle ci : Nom : attention.jpg
Affichages : 73
Taille : 1,7 Ko

    pour avoir l image juste avant le texte

    Est il aussi possible de changer la taille de la police ?

    merci d avance de vos reponse

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    non sauf à faire ta boite perso

  3. #3
    Inactif  
    Homme Profil pro
    Lycéen
    Inscrit en
    Octobre 2014
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Mayenne (Pays de la Loire)

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Octobre 2014
    Messages : 11
    Points : 16
    Points
    16
    Par défaut
    Bonjour,

    Je pense avoir une idée. Vous pouvez essayer de concevoir une fenêtre modale pour personnaliser votre boîte de dialogue.

    Avantages :

    - Un meilleur design qu'une boite standard,
    - Le choix de la taille de la boîte en px, em ou en %,
    - Utile pour accompagner l'utilisateur.
    - Proposer des options supplémentaires (inscription, connexion, pub, etc...)

    Inconvénients :

    - Difficulté à mettre en place,
    - Prend du temps en fonction de ce que voulez mettre dedans.

    Il me semble que dans une boite de dialogue standard, il n'est pas possible d'ajouter une image. Vous devez donc passer par les fenêtres modales. Tout ceci en Javascript et jQuery, bien sûr.


    J'espère vous avoir aidé.
    Bonne journée.

  4. #4
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Bonjour,

    J'ai ça dans mes cartons :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
     
    <!--<Developed and experimented by -----SlayerOffice------- >-->
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
    <title>Custom alert</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
     
    <style type="text/css">
    #modalContainer {
    	position:absolute;
    	width:100%;
    	height:100%;
    	top:0px;
    	left:0px;
    	z-index:10000;
    	background-image:url(tp.png); /* required by MSIE to prevent actions on lower z-index elements */
    }
     
    #alertBox {
    	position:relative;
    	width:300px;
    	min-height:100px;
    	margin-top:200px;
    border-style: groove; /*groove ridge outset inset*/
    	background-color: #fff;
    	background-repeat:no-repeat;
    	box-shadow: 2px 2px #ccc;
    	background-position:20px 30px;
    }
     
    #modalContainer > #alertBox {
    	position:fixed;
    }
     
    #alertBox h1 {
    	text-align:center;
    	background-color: #f60;
    	font-family: arial;
    	font-size: 9pt;
    	color: #FFF;
    	font-weight: bold;
    	border: none;
    	margin:0;
    }
     
    #alertBox p {
    /*
    	font:0.7em verdana,arial;
    	height:50px;
    	padding-left:5px;
    	margin-left:5px;
    */
    	font-family: arial;
    	font-size: 9pt;
    	color: #000000;
    	font-weight: normal;
    }
     
    #alertBox #closeBtn {
    	display:block;
    	position:relative;
    	margin:5px ;
    	margin-left:110px ;
    	margin-top:20px ;
    	margin-bottom:20px ;
    	padding:3px;
    	width:80px;
    	font:0.7em arial,verdana;
    	text-transform:uppercase;
    	text-align:center;
    	color:black;
    	background-color:#D4D4D4;
    	border-radius : 2px;
    	text-decoration:none;
    }
     
    #alertBox #closeBtn:hover{
    	background-color:#999;
    	color:#fff;
    }
     
    /* unrelated styles */
     
    #mContainer {
    	position:relative;
    	width:600px;
    	margin:auto;
    	padding:5px;
    	border:2px solid #000;
    	font:0.7em verdana,arial;
    }
     
    h1,h2 {
    	margin:0;
    	margin-right:2px;
    	padding:4px;
    	font:bold 1.5em verdana;
    	border-bottom:1px solid #000;
    }
     
    code {
    	font-size:1.2em;
    	color:#069;
    }
     
    #credits {
    	position:relative;
    	margin:25px auto 0px auto;
    	width:350px;
    	font:0.7em verdana;
    	border-top:1px solid #000;
    	border-bottom:1px solid #000;
    	height:90px;
    	padding-top:4px;
    }
     
    #credits img {
    	float:left;
    	margin:5px 10px 5px 0px;
    	border:1px solid #000000;
    	width:80px;
    	height:79px;
    }
     
    .important {
    	background-color:#F5FCC8;
    	padding:2px;
    }
     
    code span {
    	color:green;
    }
    </style>
    <script type="text/javascript">
     
    //var ALERT_TITLE = "NOM DE L'APPLI";
    var ALERT_BUTTON_TEXT = "Ok";
     
    if(document.getElementById) {
    	window.alert = function(titre, txt) {
    		createCustomAlert(titre, txt);
    	}
    }
     
    function createCustomAlert(titre, txt) {
    	d = document;
     
    	if(d.getElementById("modalContainer")) return;
     
    	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
    	mObj.id = "modalContainer";
    	mObj.style.height = d.documentElement.scrollHeight + "px";
     
    	alertObj = mObj.appendChild(d.createElement("div"));
    	alertObj.id = "alertBox";
    	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
    	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
    	alertObj.style.visiblity="visible";
    	h1 = alertObj.appendChild(d.createElement("h1"));
    //	h1.appendChild(d.createTextNode(ALERT_TITLE));
    	h1.appendChild(d.createTextNode(titre));
     
    	msg = alertObj.appendChild(d.createElement("p"));
    	//msg.appendChild(d.createTextNode(txt));
    	msg.innerHTML = txt;
     
    	btn = alertObj.appendChild(d.createElement("a"));
    	btn.id = "closeBtn";
    	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
    	btn.href = "#";
    	btn.focus();
    	btn.onclick = function() { removeCustomAlert();return false; }
     
    	alertObj.style.display = "block";
     
    }
     
    function removeCustomAlert() {
    	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
    }
     
    function Verif()
    	{
    	if (trim(document.getElementById('txtTexte1').value) == '')
    		{
    		alert('Nom de l\'application', '&nbsp;<img src=Stop.png height="30" width="30">&nbsp;&nbsp;&nbsp;Le premier texte est vide !');
    		}
    	else if (trim(document.getElementById('txtTexte2').value) == '')
    		{
    		alert('Nom de l\'application', '&nbsp;<img src=question.png height="30" width="30">&nbsp;&nbsp;&nbsp;Le deuxième texte est vide.');
    		}
    	}
     
    function trim(string)
    	{
    	return string.replace(/(^\s*)|(\s*$)/g,'');
    	}
     
    </script>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    </head>
    <body bgcolor="#ECF4FF">
    <form name="f1">
    <input type="text" name="txtTexte1" id="txtTexte1" size="20">
    <br>
    <input type="text" name="txtTexte2" id="txtTexte2" size="20">
    <br><br>
    <input type="button" value = "Valider" onclick="Verif();" / id=button2 name=button2>
    </form>
    </body>
    </html>

Discussions similaires

  1. [D7] Comment ajouter une image dans du RTF ?
    Par Lung dans le forum Delphi
    Réponses: 21
    Dernier message: 02/10/2006, 16h59
  2. Comment ajouter une image dans une balise div ??
    Par liv dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 05/05/2006, 11h48
  3. comment ajouter une image dans mon HTML??
    Par Mickey.jet dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 22/03/2006, 15h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo