je la recupere dans une alert mais ce que je veu c'est le mettre dans un if
Code : Tout sélectionner
if( history.previous = quelque chose) Code : Tout sélectionner
if( history.previous = quelque chose)
tu devras tester cette valeur, sans oublier que c'est une chaine de cractères, ce qui te donnerai QQ chose du stylevaleur de history est undefined
Code : Tout sélectionner
if( history.previous == 'undefined'){
......
}Code : Tout sélectionner
var historik = history.previous;
function Redirige(){
alert("history : " + historik);
if( historik == "undefined")
window.close();
else
window.location.href="http://www.monsite.fr"
}
Code : Tout sélectionner
length
back()
forward()
go()Code : Tout sélectionner
<html>
<head>
</head>
<body>
<script type="text/JavaScript">
try{
for(prop in window.history){
document.write('Prop = ' + prop + ' val = ' + window.history[prop] + '<br />');
}
}catch (error){
alert('ERREUR : ' + error);
}
document.write("Pages visitées = " + window.history.length + '<br />');
</script>
<a href="./ess1.html">Suivante</a>
</body>
</html>Code : Tout sélectionner
<html>
<head>
</head>
<body>
<script type="text/JavaScript">
document.write("Pages visitées = " + window.history.length + '<br />');
</script>
</body>
</html>Code : Tout sélectionner
if(window.history.length == 1){
message = "Plus de ";
}else{
message = "Il reste " + (window.history.length - 1);
}
alert(message + " pages dans l'historique);Code : Tout sélectionner
<script language="JavaScript" type="text/javascript">
function Redirige(){
if(window.history.length>=1) {
window.location.href="http://www.monsite.fr";
} else {
self.close();
}
}
</script>