Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > jQuery
jQuery Forum d'entraide sur le framework jQuery. Avant de poster : Tutoriels jQuery, FAQ jQuery, Tous les tutoriels JavaScript, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 01/08/2011, 07h54   #1
Membre habitué
 
Avatar de thebarbarius
 
Inscription : octobre 2008
Messages : 745
Détails du profil
Informations forums :
Inscription : octobre 2008
Messages : 745
Points : 139
Points : 139
Par défaut Faire apparaitre une modal box

Bonjours,

J'ai suivis ce petit tutoriel pour la création d'une modal box.

Mais helas cela ne me suffit pas, je souhaiterai savoir en plus comment lancer la modalbox au chargement de la page.

Merci
thebarbarius est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/08/2011, 12h27   #2
Membre éclairé
 
Homme
Webmaster
Inscription : septembre 2007
Messages : 376
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Webmaster
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : septembre 2007
Messages : 376
Points : 377
Points : 377
Coucou,

pour faire propre, j'ai séparé l'évènement click de ton lien avec l'affichage du dialog en elle même. Ceci te permettra ainsi de faire appel à ton dialog, de n'importe où de ton JS. Voici le JS que j'obtiens :

Code :
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
 
$(document).ready(function() {
 
   //on affiche le dialog à l'ouverture de la page
   showDialog('#dialog2');	
 
   //select all the a tag with name equal to modal
   $('a[name=modal]').click(function(e) {
 
      //Cancel the link behavior
      e.preventDefault();
 
      //Get the A tag
      var id = $(this).attr('href');
 
      showDialog(id);
 
   });
 
   //if close button is clicked
   $('.window .close').click(function (e) {
 
      //Cancel the link behavior
      e.preventDefault();
 
      $('#mask').hide();
      $('.window').hide();
   });		
 
   //if mask is clicked
   $('#mask').click(function () {
      $(this).hide();
      $('.window').hide();
   });			
 
});
 
function showDialog(id)
{
   //Get the screen height and width
   var maskHeight = $(document).height();
   var maskWidth = $(window).width();
 
   //Set heigth and width to mask to fill up the whole screen
   $('#mask').css({'width':maskWidth,'height':maskHeight});
 
   //transition effect		
   $('#mask').fadeIn(1000);	
   $('#mask').fadeTo("slow",0.8);	
 
   //Get the window height and width
   var winH = $(window).height();
   var winW = $(window).width();
 
   //Set the popup window to center
   $(id).css('top',  winH/2-$(id).height()/2);
   $(id).css('left', winW/2-$(id).width()/2);
 
   //transition effect
   $(id).fadeIn(2000); 
}
Comme tu peux le voir, la fonction showDialog attend en paramètre le sélecteur du div à afficher
Finality est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 03/08/2011, 20h24   #3
Membre habitué
 
Avatar de thebarbarius
 
Inscription : octobre 2008
Messages : 745
Détails du profil
Informations forums :
Inscription : octobre 2008
Messages : 745
Points : 139
Points : 139
Merci beacoup du coup de main
thebarbarius est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 13h42.


 
 
 
 
Partenaires

Hébergement Web