Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

onBlur, self.focus: form headache

Posted on 2004-04-15
1
Medium Priority
?
858 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

610 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