nabst Posted May 4, 2008 Share Posted May 4, 2008 (edited) Salut, Sous un nom farfelue, je cherche simplement un script javascript qui me ferais l'équivalent de ça (php): <?php $var=rand(1, 2); $code1= 'script javascript 1'; $code2= 'script javascript 2'; if ( $var ==1 ) { echo $code1; } if ( $var == 2 ) { echo $code2; } ?></div> C'est à dire, un script qui execute aléatoirement l'un ou l'autre script. En connaissait vous? Merci. Edited May 4, 2008 by nabst Link to comment Share on other sites More sharing options...
Ifmy Posted May 4, 2008 Share Posted May 4, 2008 Bonjour, function f1(){...}function f2(){...}var rand = Math.round(Math.random());rand == 0 ? f1() : f2(); ça doit fonctionner Link to comment Share on other sites More sharing options...
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