If window.location = " "

Fermé
jean r - 26 sept. 2013 à 20:16
animostab Messages postés 2829 Date d'inscription jeudi 10 mars 2005 Statut Membre Dernière intervention 11 novembre 2019 - 26 sept. 2013 à 22:09
Bonjour,
sur mon site qui n'est pas encore accessible, j'aimerai créer un code javascript tel que

if ()
{
window.location = "http://mosite.com/";
}
else (){
window.history.back()
}

comment faire ?
Merci

1 réponse

animostab Messages postés 2829 Date d'inscription jeudi 10 mars 2005 Statut Membre Dernière intervention 11 novembre 2019 738
Modifié par animostab le 26/09/2013 à 22:27
Voila un code qui te met retour page précédente a toutes les pages qui ne sont pas http://monsite.com/

<script type="text/javascript">

var Goback ='<A href="javascript:history.go(-1)">Retour</A>';

if (window.location != "http://monsite.com/")
{document.getElementById('divback').innerHTML = Goback};
else
{document.getElementById('divback').innerHTML = ''}; /*attention ici c'est 2 ' et pas 1" */

</script>

<div id="divback"></div>


Un petit merci vaut mieux qu'une grande ignorance
0