begin process at 2008 08 08 21:06:06
1 223 607 membres
365 nouveaux aujourd'hui
14 230 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

POPUP EN ASP


Information sur la source

Description

cette fonction affiche ou ferme un popup
ENTREES : URL (adresse de la page à afficher dans le popup : optionnel)
NomPopup (nom du popup : optionnel)
BarreDesLiens (drapeau indiquant l'affichage ou non de la barre de liens : yes,no : optionnel, par defaut = "no")
BarreDesMenus (drapeau indiquant l'affichage ou non de la barre de menu : yes,no : optionnel, par defaut = "no")
BarreNav (drapeau indiquant l'affichage ou non de la barre de navigation : yes,no : optionnel, par defaut = "no")
BarreDuStatut (drapeau indiquant l'affichage ou non de la barre de statut : yes,no : optionnel, par defaut = "no")
ZoneAdresse (drapeau indiquant l'affichage ou non de la zone d'adresse : yes,no : optionnel, par defaut = "no")
Ascenseurs (drapeau indiquant l'affichage ou non des scrollings : yes,no,auto : optionnel, par defaut = "no")
Dimensionnable (drapeau indiquant si le popup est ou n'est pas redimensionnable : yes,no : optionnel, par defaut = "no")
Hauteur (Hauteur du popup en pixels : nombre entier)
Largeur (Largeur du popup en pixels : nombre entier)
PositionH (Position horizontale en pixels sur l'écran : nombre entier : optionnel, par defaut = 0)
PositionV (Position verticale en pixels sur l'écran : nombre entier : optionnel, par defaut = 0)
PleinEcran (drapeau indiquant l'affichage plein écran ou non du popup : yes,no : optionnel, par defaut = "no")
TitrePopup (Titre du popup : optionnel)
Texte (texte à afficher dans le popup : optionnel)
Choix (drapeau indiquant l'ouverture ou la fermeture du popup : "0","ouverture","yes" = ouverture, "1","fermeture","no" = fermeture)
SORTIES : NEANT

Source

  • function PopUp(URL,NomPopup,BarreDesLiens,BarreDesMenus,BarreNav,BarreDuStatut,ZoneAdresse,Ascenseurs,Dimensionnable,Hhauteur,Largeur,PositionH,PositionV,PleinEcran,TitrePopup,Texte,Choix)
  • Dim strRetour,sep
  • sep = " "
  • if (BarreDesLiens="") then BarreDesLiens="no" end if
  • if (BarreDesMenus="") then BarreDesMenus="no" end if
  • if (BarreNav="") then BarreNav="no" end if
  • if (BarreDuStatut="") then BarreDuStatut="no" end if
  • if (ZoneAdresse="") then ZoneAdresse="no" end if
  • if (Ascenseurs="") then Ascenseurs="no" end if
  • if (Dimensionnable="") then Dimensionnable="no" end if
  • if (Hhauteur="") then Hhauteur="100" end if
  • if (Largeur="") then Largeur="250" end if
  • if (PositionH="") then PositionH="100" end if
  • if (PositionV="") then PositionV="200" end if
  • if (PleinEcran="") then PleinEcran="no" end if
  • strRetour = "<script language=""JavaScript"">" & vbcrlf
  • strRetour = strRetour & sep & "var w;" & vbcrlf
  • SELECT CASE LCase(Choix)
  • CASE "o","ouverture","yes","0","open"
  • strRetour = strRetour & sep & "w = window.open ("""&URL&""",'"&NomPopup&"','directories="&BarreDesLiens&",menubar="&BarreDesMenus&",toolbar="&BarreNav&",status="&BarreDuStatut&",location="&ZoneAdresse&",scrollbars="&Ascenseurs&",resizable="&Dimensionnable&",height="&Hhauteur&",width="&Largeur&",top="&PositionV&",left="&PositionH&",fullscreen="&PleinEcran&"');" & vbcrlf
  • strRetour = strRetour & sep & "w.document.write(""<html>"");" & vbcrlf
  • IF TitrePopup <> "" THEN
  • strRetour = strRetour & sep & "w.document.write(""<TITLE>"&TitrePopup&"</TITLE>"");" & vbcrlf
  • END IF
  • strRetour = strRetour & sep & "w.document.write(""<body>"");" & vbcrlf
  • IF Texte <> "" THEN
  • strRetour = strRetour & sep & "w.document.write(""<div align=center>"&Texte&"</div>"");" & vbcrlf
  • END IF
  • strRetour = strRetour & sep & "w.document.write(""<br>"");" & vbcrlf
  • strRetour = strRetour & sep & "w.document.write(""<div align=center><a href='javascript:self.close();'>fermer</a></div>"");" & vbcrlf
  • strRetour = strRetour & sep & "w.document.write(""</body>"");" & vbcrlf
  • strRetour = strRetour & sep & "w.document.write(""</html>"");" & vbcrlf
  • CASE "n","fermeture","no","1","close"
  • ' temporisation
  • strRetour = strRetour & sep & "temporisateur(1,""FermerFenetre(w)"");" & vbcrlf
  • END SELECT
  • strRetour = strRetour & "</script>" & vbcrlf
  • response.write(strRetour)
  • end function
  • function PopupSimple(URL,NomPopup,Hhauteur,Largeur,TitrePopup,Texte,Choix)
  • PopupSimple = PopUp(URL,NomPopup,"","","","","","","",Hhauteur,Largeur,"","","",TitrePopup,Texte,Choix)
  • end function
  • A ceci, il faut ajouter la fonction JavaScript :
  • function temporisateur(seconde,fonction) {
  • setTimeout(fonction,seconde*1000);
  • }
  • function FermerFenetre(NomFenetre){
  • if (NomFenetre.document) { NomFenetre.close(); }
  • }
  • qui permettent de temporiser avant la fermeture du popup
function PopUp(URL,NomPopup,BarreDesLiens,BarreDesMenus,BarreNav,BarreDuStatut,ZoneAdresse,Ascenseurs,Dimensionnable,Hhauteur,Largeur,PositionH,PositionV,PleinEcran,TitrePopup,Texte,Choix)
	Dim strRetour,sep

	sep = " "
	if (BarreDesLiens="") then BarreDesLiens="no" end if
	if (BarreDesMenus="") then BarreDesMenus="no" end if
	if (BarreNav="") then BarreNav="no" end if
	if (BarreDuStatut="") then BarreDuStatut="no" end if
	if (ZoneAdresse="") then ZoneAdresse="no" end if
	if (Ascenseurs="") then Ascenseurs="no" end if
	if (Dimensionnable="") then Dimensionnable="no" end if
	if (Hhauteur="") then Hhauteur="100" end if
	if (Largeur="") then Largeur="250" end if
	if (PositionH="") then PositionH="100" end if
	if (PositionV="") then PositionV="200" end if
	if (PleinEcran="") then PleinEcran="no" end if
	strRetour = "<script language=""JavaScript"">" & vbcrlf
	strRetour = strRetour & sep & "var w;" & vbcrlf
	SELECT CASE LCase(Choix)
		CASE "o","ouverture","yes","0","open"
			strRetour = strRetour & sep & "w = window.open ("""&URL&""",'"&NomPopup&"','directories="&BarreDesLiens&",menubar="&BarreDesMenus&",toolbar="&BarreNav&",status="&BarreDuStatut&",location="&ZoneAdresse&",scrollbars="&Ascenseurs&",resizable="&Dimensionnable&",height="&Hhauteur&",width="&Largeur&",top="&PositionV&",left="&PositionH&",fullscreen="&PleinEcran&"');" & vbcrlf
			strRetour = strRetour & sep & "w.document.write(""<html>"");" & vbcrlf
			IF TitrePopup <> "" THEN
				strRetour = strRetour & sep & "w.document.write(""<TITLE>"&TitrePopup&"</TITLE>"");" & vbcrlf
			END IF
			strRetour = strRetour & sep & "w.document.write(""<body>"");" & vbcrlf
			IF Texte <> "" THEN
				strRetour = strRetour & sep & "w.document.write(""<div align=center>"&Texte&"</div>"");" & vbcrlf
			END IF
			strRetour = strRetour & sep & "w.document.write(""<br>"");" & vbcrlf
			strRetour = strRetour & sep & "w.document.write(""<div align=center><a href='javascript:self.close();'>fermer</a></div>"");" & vbcrlf
			strRetour = strRetour & sep & "w.document.write(""</body>"");" & vbcrlf
			strRetour = strRetour & sep & "w.document.write(""</html>"");" & vbcrlf
		CASE "n","fermeture","no","1","close"
			' temporisation
			strRetour = strRetour & sep & "temporisateur(1,""FermerFenetre(w)"");" & vbcrlf
	END SELECT
	strRetour = strRetour & "</script>" & vbcrlf
	response.write(strRetour)
end function
function PopupSimple(URL,NomPopup,Hhauteur,Largeur,TitrePopup,Texte,Choix)
	PopupSimple = PopUp(URL,NomPopup,"","","","","","","",Hhauteur,Largeur,"","","",TitrePopup,Texte,Choix)
end function

A ceci, il faut ajouter la fonction JavaScript :
function temporisateur(seconde,fonction) {
	setTimeout(fonction,seconde*1000);
}
function FermerFenetre(NomFenetre){
	if (NomFenetre.document) {  NomFenetre.close(); }
}
qui permettent de temporiser avant la fermeture du popup 

Conclusion

Rien de bien compliqué!
Vous pouvez modifier le temps de temporisation de fermeture du popup
Comme vous le voyez, vous pouvez ouvrir un popup par défaut, ayant les atttributs par défaut sinon, appelez la fonction Popup avec tous les paramètres que vous voulez!

Voici une page asp exemple :

&lt;%
function PopUp(URL,NomPopup,BarreDesLiens,BarreDesMenus,BarreNav,BarreDuStatut,ZoneAdresse,Ascenseurs,Dimensionnable,Hhauteur,Largeur,PositionH,PositionV,PleinEcran,TitrePopup,Texte,Choix)
Dim strRetour,sep

sep = " "
if (BarreDesLiens="") then BarreDesLiens="no" end if
if (BarreDesMenus="") then BarreDesMenus="no" end if
if (BarreNav="") then BarreNav="no" end if
if (BarreDuStatut="") then BarreDuStatut="no" end if
if (ZoneAdresse="") then ZoneAdresse="no" end if
if (Ascenseurs="") then Ascenseurs="no" end if
if (Dimensionnable="") then Dimensionnable="no" end if
if (Hhauteur="") then Hhauteur="100" end if
if (Largeur="") then Largeur="250" end if
if (PositionH="") then PositionH="100" end if
if (PositionV="") then PositionV="200" end if
if (PleinEcran="") then PleinEcran="no" end if
strRetour = "&lt;script language=""JavaScript""&gt;" & vbcrlf
strRetour = strRetour & sep & "var w;" & vbcrlf
SELECT CASE LCase(Choix)
CASE "o","ouverture","yes","0","open"
strRetour = strRetour & sep & "w = window.open ("""&URL&""",'"&NomPopup&"','directories="&BarreDesLiens&",menubar="&BarreDesMenus&",toolbar="&BarreNav&",status="&BarreDuStatut&",location="&ZoneAdresse&",scrollbars="&Ascenseurs&",resizable="&Dimensionnable&",height="&Hhauteur&",width="&Largeur&",top="&PositionV&",left="&PositionH&",fullscreen="&PleinEcran&"');" & vbcrlf
strRetour = strRetour & sep & "w.document.write(""&lt;html&gt;"");" & vbcrlf
IF TitrePopup &lt;&gt; "" THEN
strRetour = strRetour & sep & "w.document.write(""&lt;TITLE&gt;"&TitrePopup&"&lt;/TITLE&gt;"");" & vbcrlf
END IF
strRetour = strRetour & sep & "w.document.write(""&lt;body&gt;"");" & vbcrlf
IF Texte &lt;&gt; "" THEN
strRetour = strRetour & sep & "w.document.write(""&lt;div align=center&gt;"&Texte&"&lt;/div&gt;"");" & vbcrlf
END IF
strRetour = strRetour & sep & "w.document.write(""&lt;br&gt;"");" & vbcrlf
strRetour = strRetour & sep & "w.document.write(""&lt;div align=center&gt;&lt;a href='javascript:self.close();'&gt;fermer&lt;/a&gt;&lt;/div&gt;"");" & vbcrlf
strRetour = strRetour & sep & "w.document.write(""&lt;/body&gt;"");" & vbcrlf
strRetour = strRetour & sep & "w.document.write(""&lt;/html&gt;"");" & vbcrlf
CASE "n","fermeture","no","1","close"
' temporisation
strRetour = strRetour & sep & "temporisateur(1,""FermerFenetre(w)"");" & vbcrlf
END SELECT
strRetour = strRetour & "&lt;/script&gt;" & vbcrlf
response.write(strRetour)
end function
function PopupSimple(URL,NomPopup,Hhauteur,Largeur,TitrePopup,Texte,Choix)
PopupSimple = PopUp(URL,NomPopup,"","","","","","","",Hhauteur,Largeur,"","","",TitrePopup,Texte,Choix)
end function
%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Acceuil&lt;/TITLE&gt;
&lt;META NAME="Generator" CONTENT="EditPlus"&gt;
&lt;META NAME="Author" CONTENT=""&gt;
&lt;META NAME="Keywords" CONTENT=""&gt;
&lt;META NAME="Description" CONTENT=""&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
function temporisateur(seconde,fonction) {
setTimeout(fonction,seconde*1000);
}
function FermerFenetre(NomFenetre){
if (NomFenetre.document) {  NomFenetre.close(); }
}
//--&gt;
&lt;/script&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;%
call PopupSimple("","Test","150","300","Ceci est un test","Bonjour toua!","0")
call PopupSimple("","Test","","","","","1")
%&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;

  • signaler à un administrateur
    Commentaire de fr64 le 25/09/2003 11:29:01

    C'est du JavaScript qui avance masqué

  • signaler à un administrateur
    Commentaire de Tanis49 le 02/11/2004 17:29:17

    c parlant comme code.....
    un vrais regal.....

  • signaler à un administrateur
    Commentaire de io_ost le 11/05/2006 12:59:06

    bon code bien expliquer

Ajouter un commentaire

Pub



Appels d'offres

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS