?
Solved

onBlur, self.focus: form headache

Posted on 2004-04-15
1
Medium Priority
?
867 Views
Last Modified: 2008-02-01
Hi.
I have a ** body onblur="self.focus();"  ** tag to keep my page on top, and it works fine, except for that my form fields wont work!

It should have been obious for me: when you focus a form field, your page loses focus, and tries to regain it, so you can't write in the field (darn!).

Can anyone help me on this one?
0
Comment
Question by:tomwoods
1 Comment
 
LVL 12

Accepted Solution

by:
lil_puffball earned 375 total points
ID: 10837970
Here's a workaround. Unfortunately, it doesn't work if the user clicks on the form, then on another page. I think this is the closest you'll get though.

Add this to the top of your page:

<script>
function init(){
  for(i=0;i<document.forms.length;i++){
    for(j=0;j<document.forms[i].elements.length;j++){
      document.forms[i].elements[j].onmousedown=function(){document.body.onblur=null;this.focus();}
      document.forms[i].elements[j].onfocus=function(){document.body.onblur=null;this.focus();}
      document.forms[i].elements[j].onblur=function(){document.body.onblur=function(){self.focus();}}
    }
  }
}
</script>

<body onblur="self.focus();" onload="init();">
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question