Manually setting focus to a element in TV

2019-09-09 20:36发布

问题:

I can't find any method in the Documentation to manually set the focus to an element. It is supposed to support the DOM Element class, but when i do

var elem = ele.ownerDocument.getElementById("start");
elem.focus();

it does nothing. elem is correctly set, but it doesn't recognize the focus() method.

回答1:

Apple's TVJS Framework doesn't provide any method in his classes to manually focus an element.

Neither in the standard Document Object Module classes it incorporates have any kind of method to directly access the DOM and focus an element.

The closes thing available is the autoHighlight attribute which allows to focus on render some specific elements in certain positions.



回答2:

In pure js you can document.getElementById("start").autofocus; : On page load input is autofocus



回答3:

Use autoHighlight for this purpose.

autoHightlight="true"

Both the containing element and one child element have to be set to true.