Jump to content
Sign in to follow this  
nabst

[Recherche] Script Javascript de rotation de script.

Rate this topic

Recommended Posts

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 by nabst

Share this post


Link to post
Share on other sites

Bonjour,

function f1()
{
...
}
function f2()
{
...
}
var rand = Math.round(Math.random());
rand == 0 ? f1() : f2();

ça doit fonctionner ^^

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...