0

I'm quite nooby in using Cobalt. I try to create a simple app (just couple of pages) using HTML, CSS and JS. Static content looks fine in Cobalt. But mouse clicks and events from keyboard aren't handled. I mean code like

document.addEventListener("keydown", e => { do something });

//or

var links = document.getElementsByClassName("link");
for (var i = 0; i < links.length; i++) {
  links[i].addEventListener("click", function() {
    document.location.href = URL_PAGE;
  });
}

works in Chrome, but doesn't work in Cobalt. When I click something or press buttons on a keyboard - just nothing happens. For now I haven't found how to handle user events to make them work in Cobalt.

Any help would be very appreciated.

Thank in advance, Evgeniy

Evgeniy
  • 540
  • 4
  • 17
  • Hi Evgeniy, so what you have there should work. In your example above, what is "do something"? For example if you modify the dom, you should see it update on keypress. Note that navigation may not work as you expect in Cobalt, so depending on URL_PAGE, modifying "document.location.href" may not do anything. Try chnaging the DOM or calling console.log() instead. If you hit CTRL+O once or twice, you can open a console where you can interactively type and execute JavaScript. – Andrew Top Oct 25 '17 at 00:17
  • @AndrewTop, thanks for help. Appears that I just had errors in my script. I fixed them and now everything work fine. Sorry for a false alarm. – Evgeniy Oct 26 '17 at 08:03

1 Answers1

0

Appears that I just had errors in my script. I fixed them and now everything work fine. Sorry for a false alarm.

Evgeniy
  • 540
  • 4
  • 17