minimouse 0 Posted May 14, 2010 Share Posted May 14, 2010 Bonjour à tous, je cherchais un script pour afficher des phrases de façon aléatoire et que sur ces phrases il y ait un lien. J'ai trouvé un code en javascript qui correspond tout à fait mais comment rajouter les liens ? <script LANGUAGE="JavaScript">phrase = new Array(2) phrase[0] = "phrase n°1"; phrase[1] = "phrase n°2"; phrase[2] = "phrase n°3"; phrase[3] = "phrase n°4";phrase[4] = "phrase n°5"; index = Math.floor(Math.random() * phrase.length);document.write(phrase[index]); </SCRIPT> merci d'avance pour vos réponses Link to post Share on other sites
Portekoi 10 Posted May 14, 2010 Share Posted May 14, 2010 BOnjour, Je n'ai pas testé mais essaie comme ca : <script LANGUAGE="Javascript">phrase = new Array(5);phrase[0] = "<a href='lien1.php'>phrase n°1</a>"; phrase[1] = "<a href='lien2.php'>phrase n°2</a>"; phrase[2] = "<a href='lien3.php'>phrase n°3</a>"; phrase[3] = "<a href='lien4.php'>phrase n°4</a>";phrase[4] = "<a href='lien5.php'>phrase n°5</a>"; index = Math.floor(Math.random() * phrase.length);document.write(phrase[index]); </script> Portekoi Link to post Share on other sites
minimouse 0 Posted May 17, 2010 Author Share Posted May 17, 2010 MERCI BEAUCOUP, ça fonctionne ... Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now