Question

I'm trying to add a button to an app that uses Crafty, but, unlike the other buttons, I want this one to redirect the user to a different URL.

Notice that no-one ever taught me how to use Coffee or JavaScript, so I'm really new.

I'm trying to use the redirection here:

cfg.onClickTeacher = -> 
      preloadScene(CFG.ASSETS_MAIN, -> "www.my-site/teacher")

But it's not working, so, what do I have to do?

Was it helpful?

Solution

That doesn’t involve Crafty, and is the same as in JavaScript.

cfg.onClickTeacher = ->
    window.location.href = 'http://example.com/'

(Relative URLs work too.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top