search
HomeWeb Front-endHTML TutorialIPTV small window plays video and the solution to the problem that the page focus cannot be moved_html/css_WEB-ITnose

On the IPTV HD page, when playing video in a small window, on some set-top boxes (such as HD ZTE, HD Daya 4904), the focus will not move, that is, the buttons will not respond. I have been troubled by this bug for a long time. Although I know the solution, I only know it but not the reason. I did an experiment today and the results are analyzed as follows:

When the page calls the video playback method, we know that the actual work done by the code is to splice the parameters including the video ID, video window position, video window size, etc. into the URL. , assigned to the src of the iframe used to play the video, the playback control will be run on the current page (I guess this may be the case. Of course, this playback control is only supported on IPTV set-top boxes, and an error will be reported on the PC side, because The PC browser does not recognize the object created by the code for playing the video). At this time, the iframe is in the focus state, that is, the current focus of the page is on this iframe. When we operate the remote control to move the focus, the focus does not move on ZTE and Daya 4904 HD set-top boxes.

The reason is that the focus obtained by the iframe has not been removed, or its focus cannot be transferred to other elements of the page. Therefore, the page becomes unresponsive when the remote control direction keys are pressed.

Now let’s prove this conclusion.

In an HTML page, many elements can gain and lose focus, such as a, img, input and other tags with href or src attributes. In the high-definition page, the focus of the element (here refers to the div tag we actually use) is not the focus in the html page, but changes its css style through javascript to mark the current position. We call it the focus. This is an appearance. , used to tell the user (the actual operator) the location of the object to be operated on the page. It is not in the .focus state, which is different from the focus obtained by the above label (red mark). The focusable element can obtain focus in the BOM through the .focus method. Some browsers will display a dotted box around the focused element. At this time, the focus can be switched by pressing the Tab key on the keyboard.

In other words, the focus obtained by the iframe used to play the video is not the same thing as the focus we describe in the IPTV page. The former is the real focus in the HTML page, and the latter is a mark, a visual mark we use for positioning on the page (eventually on the TV). The switching is actually to change the CSS style through JavaScript, resulting in a large change in color, to achieve A visual effect used to tell the user the current location of the object to be manipulated.

Since this focus is not that focus, the page element is handled differently when the focus is switched, that is, when a focus loss or focus event occurs. The real focus on the page can only be switched to elements that can accept it, that is, tags with href or src attributes. When these elements do not exist on the page, or when these elements are far away, the focus will not It will be switched normally and will remain in the original position. At this time, the page is in a focus-locked state (guess by yourself).

Knowing the reason, we found a way to solve the original problem.

We can solve it in two ways:

Method 1. Add elements to the page that can accept the real focus, such as a, img, input and other tags. In order to avoid the impact of the added tags To make the page beautiful, you can set its width and height to 0, which is equivalent to hiding it from the page. You can also set the display:none style for it. Note that although it is hidden, it actually exists on the page. Of course, it is best to add the label for accepting the real focus here near the element that is reluctant to put the real focus. It is too far away. In order to give you the focus, they have to buy a train ticket. Do you think they are willing? Woolen cloth. Of course, in some browsers (this is actually a high-definition set-top box), the element with real focus (that is, the iframe used to play the video) will be more generous at this time. You can buy a plane ticket out of your own pocket just to give focus to thousands of miles. .

Method 2: Change the elements near the element with real focus to elements that can accept the real focus of the page. What is said here is a bit confusing. For example, if you want to move the focus of the iframe to the div near it, then you can set this div to an element that can accept the real focus of the page. How to set it up? You can add a tabIndex attribute to the div. The value of this attribute can be any value between 1 and 32767. At this time, the div will be added to the sequence of TAB keys.

Here is a brief introduction to the rules for moving focus between elements with the tabIndex attribute set. When the viewer uses the Tab key to move the focus on the page, the focus will first move to the element with the smallest tabIndex attribute value, and finally to the element with the largest tabIndex attribute. The movement ends on the element with the value of the tabIndex attribute. If there are two elements with the same tabIndex attribute, the order in which the elements appear in the html code shall prevail. The default tabIndex attribute is 0 and will be arranged after all elements with specified tabIndex. So for method two above, it is best to set the tabIndex attribute value of the div to 1 instead of 0. And if the tabIndex attribute is set to a negative value (such as tabIndex="-1"), then this element will be excluded from the sequence of TAB keys.

Now back to the original problem we wanted to solve.

For the above method one, it is feasible for us to use the a tag on HD ZTE and HD Daiya 4904 set-top boxes. We have always done this. After processing, the focus can be moved normally on other devices. There is no unsupported impact on HD set-top boxes. We haven't tested the img and input tags, but I believe it will work.

As for method two, I tested the HD ZTE and HD Daya 4904 set-top boxes and found that it was feasible, which verified my idea. However, I did not test the HD set-top box that can move the focus normally. Will it work? Because there is an abnormal problem with this method. One phenomenon here is that after setting the tabIndex attribute on a div, a focus box will appear around the div on the set-top box. Although this is a normal phenomenon, it is not beautiful enough after all. Of course, there are ways to remove this focus box, which is discussed later. , no discussion.

Speaking of this focus box, by the way, after gaining focus, the element has a dotted frame, and there are always people who go to great lengths to remove it. In fact, this is undoubtedly a trampling on the usability of the page. We also need to consider the needs of certain special groups of people, such as experts who do not use a mouse, poor people with broken mouses, or people with visual impairments. According to an article, removing the dotted box is illegal in the United States. This is a form of discrimination against the visually impaired! From here we can see that the United States respects human rights. This is evidence and is also based on user experience and humanization considerations. After all, your products are used and served by people. But having said that, we are discussing the performance on the set-top box, so it is best to remove the focus box, but the American attitude is worth learning.

Finally, when the page focus is accepted by the a tag, because the a tag supports the remote control direction keys to move the focus, it has a similar function to the Tab key (for example, all SD pages that use the a tag to accept focus), small windows There will be no problem of being unable to move the focus while playing the video. This also proves the above conclusion.

There is a problem left here, that is, when the iframe used to play the video is set to tabIndex="-1", will the focus of the page be unable to move? Due to time constraints, no testing has been done.

It was written in a hurry without objective analysis and verification. Some opinions are inevitably biased. Criticisms and corrections are welcome.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool