Tabindex to skip iframe but not content inside

前端 未结 1 1803
清歌不尽
清歌不尽 2021-01-20 01:06

I have a page with an iframe on it, and the iframe contains a form. Outsie my iframe i have more forms.

The input elements inside the iframe are tabindex 1, 2, 3, 4,

相关标签:
1条回答
  • 2021-01-20 02:13

    To answer part of your question, the body element inside the iframe is a focusable element.

    You can prevent this effect by setting tabindex to -1 on the body of the loaded frame. For example:

    outer.html:

    <body>
     <iframe src="inner.html"></iframe>
     <input />
     <input />
     <input />
     <input />
    </body>
    

    inner.html:

    <body tabindex="-1">
     <input />
     <input />
     <input />
     <input />
    </body>
    
    0 讨论(0)
提交回复
热议问题