JavaScript fails to use focus of to set the focus

  • 2020-03-30 03:52:22
  • OfStack

I encountered a small problem yesterday when I modified the EPG page on the set-top box. When the user buys the game, the purchase confirmation dialog box pops up. The default focus of the dialog box must stay on the "cancel" button. This is a simple requirement that can be implemented using the focus() method of JavaScript. A simple code example is as follows:


document.getElementById("cancel").focus()

But sadly, the set-top box is really a big hole. Since it is compatible with all existing set-top box models, eight set-top boxes need to be adapted. And then there's the problem! A zte B600 set-top box simply can't focus on the cancel button. Here is my solution:

After more than an hour of toss and turn, finally the big BOSS appeared, simply said a word to solve the problem! It is possible to actively call flur() to cancel the original focus!


document.getElementById("purchase").flur()

Then we solved the problem. Have to feel! In the process of solving this problem, his ideas are actually quite correct, but the scope of knowledge is obviously not enough. General programmers and senior programmers in addition to the problem solving ideas, there is also a gap in experience and knowledge!


Related articles: