Le web de Dominique Guebey – Bazar informatique

Page web  : http://www.dg77.net/tekno/manuel/jscript.htm


   D o m i n i q u e   G u e b e y    J u n g l e      Bazar informatique

Javascript, exemples

Sommaire

Retour à la page précédente

<div class="bouton">
  <a title="Précédent" 
  onmouseover="self.status=document.referrer;return true" 
  href="javascript:history.go(-1)">
    <=
  </a>
</div>

Nom complet de la page html

function chempag() { 
var chempar = window.location.pathname;
return chempar
}

Date et heure

function horodat() { 
var dat = new Date();
var jma = dat.getFullYear() + '-' + (dat.getMonth()+1) + '-' + dat.getDate();
var hor = dat.getHours() + ':' + dat.getMinutes() + ':' + dat.getSeconds();
return jma + ' ' + hor;
}

Fenêtre “popup” paramétrable

Script :

function popUp(URL,Typ,Hei,Wid) {
var Opt="";
if (Typ=="console") Opt="resizable,height="+Hei+",width="+Wid;
if (Typ=="fixed") Opt="status,height="+Hei+",width="+Wid;
if (Typ=="elastic") Opt="toolbar,menubar,scrollbars,resizable,location,height="+Hei+",width="+Wid;
window.open(URL, 'newWin', Opt);
}

Redimensionnable, initialisée à 400x600 pixels. Appel :

<a href="../cpay.htm" rel="external" 
  onclick="popUp(this.href,'elastic',400,600);return false;">
  Codes pays
</a>