Forum Moderators: open

Message Too Old, No Replies

How to set Focus - NOT form based

this is nothing to do with form entry

         

stevewhome

7:46 am on Apr 15, 2004 (gmt 0)

10+ Year Member



I run a touchscreen system for corporates that access third party sites. We run a proxy to remove or swap non touchscreen friendly stuff (i.e. change onFocus to onClick for entry fields).

Some of the sites we load do not leave the keyboard scroll "focus" so that we can can use pgup and pgdn controls from the touchscreen control panel. This is generally when the site has been written using frames or div'ed tables with different z-index'es.

Does anyone know how to set the keyboard focus to an area reliably after loading (I've tried altering the z-index on the fly to have the table I want with the highest index but that does not seem to give consistent results)?

As long as I know how to do it as if I was writing the page then I can do it with the proxy on the fly.

This is IE only since we dictate the browser for the system - and it can't be swapped easily without knockon implications in other code.

Cheers

BlobFisk

2:06 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To be absolutely sure that the focus can be set to a (non-form) element, you may need to make it a link and then use javascipt to set the focus:

In the <head> (or an external js file):

<script type="text/javascript">
function setPageFocus(obj) {
document.getElementById(obj).focus();
}
</script>

In the <body> tag:

<body onload="setPageFocus('pageFocus')">

And then in the document itself surround the object you want to place the focus on with this <a>nchor information:


<a href="#" id="pageFocus">...</a>

HTH

stevewhome

7:23 am on Apr 23, 2004 (gmt 0)

10+ Year Member



Thank you for this reply - it is a complete answer to my problem - just when I had given up hope of any help coming forward. Many Thanks.