Checking browser

I have a small animation with music playing on background. Music starts on a loadscene event.
It works well on any browser except chrome. This browser only accepts to play the musci by clicking on a button.
So, I’d like to modify my animation by sending Chrome users on a specific timeline with a button to start music.
I tried this javascript but it doesn’t seem to work :

 if(navigator.userAgent.indexOf("Chrome") != -1 )
    hypeDocument.startTimelineNamed('For_google1', hypeDocument.kDirectionForward);
  hypeDocument.continueTimelineNamed('Introduction', hypeDocument.kDirectionForward, false));

Can anyone help me ? Thanks a lot


Maybe try feature detect rather than browser detect. Maybe a bit more reliable. Something like:

var isChrome = && typeof === "object";

    // start timeline A
} else {
    // continue timeline B

Just looking at this code I see a syntax error:

There’s an extra closing parenthesis at the end. It should work if this is fixed (assuming the timeline names are correct and start/continue behavior is what you want).

merci pour cette proposition malheureusement elle ne fonctionne pas.
J’ai l’impression le javascript ne se lance pas.
J’ai modifié le script comme suit :

var isChrome = && typeof === “object”;

hypeDocument.startTimelineNamed(‘For_google1’, hypeDocument.kDirectionForward);
// start timeline A
} else {
hypeDocument.startTimelineNamed(‘For_google2’, hypeDocument.kDirectionForward);

// hypeDocument.continueTimelineNamed(‘Introduction’, hypeDocument.kDirectionForward, false));
// continue timeline B
pour vérifier que le “else” se faisait.
Conclusion :
Hype continue ma timeline Introduction et ne lance pas “For_Google2” comme il devrait.
Faut-il une boucle indéfinie pour continuer le test ?
Merci d’avance

Bonjour Jonathan,
j’ai testé avec la parenthèse en mois : rien de changé.
J’ai essayé la même astuce que pour l’autre proposition : aucune des 2 timelines n’est lancée.
Est-il possible que la fonction ne soit pas lancée lors de l’action “SI charger scene” ?

Merci d’avance

Hi @DBear Dbear and @jonathan,
I tried several things to test if working :

  • I previewed the animation under Safari (Run javascript is activated in the preferences) : it didn’t work either
  • I modified the animation : I put a button at the beginning of the main timeline with the run of the javascript on click event. Then I put the suspend timeline action just after it. I tested it on the two browsers : it didn’t work
  • In order to be sure that javascript is running, il modified the function for only running this command " hypeDocument.startTimelineNamed(‘For_google2’, hypeDocument.kDirectionForward);". I tested on both bowsers : it didn’t work. So it seems that javascript isn’t running.
    I can’t understand what is mismatching ? Can anyone help ?
    Thanks a lot. Best regards

Can you share a document? or a URL where we can see what is happening.

Maybe you have something that is blocking javascript in your browser settings.

1 Like

Hi @DBear,
thanks for your return.
I will share it in the next few days because of Christmas Times.
I hope you had good time !