Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 628
  • Last Modified:

Why does a frame in a frameset receive the input focus?

Hi, I have a very simple HTML page that is divided into two frames.  Here is the code for the frameset:

<frameset rows="30,*" border="0" frameborder="0" framespacing="0" tabindex="-1">
  <frame id="frame1" name="frame1" src="about:blank" scrolling="no" style="unselectable:on;" noresize>
  <frame id="frame2" name="frame2" src="about:blank" scrolling="no" style="unselectable:on;" noresize>
</frameset>

When I load my page into a browser, I set the "src" property to an HTML page that contains a form with several input fields in it.  The user tabs through the fields based on the tab order, but when the last input field on the form is reached, and the tab key is pressed again, it is the frame that receives the input focus next, rather than the first field IN the frame.

I'm trying to figure out how to make it so that, when the user tabs through the fields on the form, he/she doesn't select the frame itself, but rather goes back to the first field on the form with TabIndex=1.

As you can see from the code snippet above, I've tried setting the frameset's tabindex property to something invalid, like -1, and I've also tried using the "unselectable" property, as referenced on Microsoft's website http://msdn.microsoft.com/library/default.asp?url=/code/list/winscripting.asp, which says that the unselectable property is a feature of the frame object.  But to no avail...the frame continues to be highlighted when the tab key is pressed on the last form field in the frame.

Any idea how to stop this behavior?

P.S.  I tried using the "unselectable" property as part of a style statement, since ASP.NET and C# (the platform that I am using) complained when I tried it this way because it didn't recognize the "unselectable" property:

<frameset rows="30,*" border="0" frameborder="0" framespacing="0" tabindex="-1">
  <frame id="frame1" name="frame1" src="about:blank" scrolling="no" unselectable="on" noresize>
  <frame id="frame2" name="frame2" src="about:blank" scrolling="no" unselectable="on" noresize>
</frameset>
0
tparke
Asked:
tparke
  • 2
1 Solution
 
GrandSchtroumpfCommented:
you can use the "onblur" attribute on your last form element to request the focus on the first form element.
0
 
tparkeAuthor Commented:
Well, that would almost work.  But the problem with that approach is that the input focus would always be moved to the first form element, in every case.  If a user were to manually move the input focus to another field on the form...say, with the mouse...then as soon as the last field lost the focus, the onblur event would force the input to the top of the form, rather than the particular location where the user chose to put the focus.

The only scenario of interest here is when the user is on the last form element and presses the tab key...which is when the cycle should begin again.  I tried capturing the tab key in the onkeydown and onkeypress events, but neither event is invoked when the tab key is pressed...

On a side note, why does Microsoft clearly state that the "Unselectable" attribute is a feature of the frameset and frame objects, but it is not recognized when added to the element?
0
 
GrandSchtroumpfCommented:
> But the problem with that approach is that the input focus would always be moved to the first form element, in every case.
I understand what you mean.  But it should not be a problem if the last element is a submit (and the last element of a form is usually a submit).
The onkeydown event is not captured when it's the "tab" key that is pressed.
0
 
Computer101Commented:
PAQed with points refunded (50)

Computer101
EE Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now