Link to home
Start Free TrialLog in
Avatar of chennarh
chennarh

asked on

Input text displays keys pressed even though it does not have focus

Hi Experts!
I have a sample HTML page, with two frames. Here is the code for focusTest.html:
<html>
<frameset rows="150,*" > 
      <frame name="frame1" src="goto.html" >
      <frame name="frame2" src="goto.html" >      
</frameset>
</html>

And here is the code for goto.html:
<html>
<body   >
<input size=10 type="text" name="text1" >
<a href="javascript:alert('Hello')">test</a>
</body>
</html>

After the page is loaded, click in the first input box, type couple of characters. Then click the SECOND test link, a Hello is alerted. At this time, the second test link has the input focus. If you hit ENTER now, alert occurs again.
But if you just  type some alphanumeric keys, the FIRST edit box shows those chars, as if it has focus.
This does not happen if the FIRST test link is clicked.

How can I avoid this? I need the text box to accept and display chars only if it has focus. Or atleast, when a char is entered, the text box should get focus.

this is in IE6.0

Thanks in advance for your prompt help!!
Avatar of Roonaan
Roonaan
Flag of Netherlands image

<a href="#" onclick="alert('Hello');return false;">test</a>

-r-
Avatar of chennarh
chennarh

ASKER

Roonaan,
Thanks for your quick response.
That did not work. And also, this is just a sample to demo that IE6.0 blur is screwed up. In my real application, I will be loading various third party html pages or some dynamic content from our servers. I cannot apply this fix all the links in those pages.

We need a workaround from the INPUT box perspective, or at the worst case within the goto.html in frame1.

chennarh
try this

<a href="javascript:alert('Hello');this.focus( );">test</a>


or this

<a href="javascript:alert('Hello');formname.controlname.blur( );">test</a>

or this if it is in a different frame

<a href="javascript:alert('Hello');top.frames[ 'framname' ].form[ 0 ].controlname.blur( );"> Test </a>
thanks jsutin, but they donot work. Problem is the input box has already lost focus, i tested with debug statements. Please refer to my earlier comment.
Hi!

Try this, work fine for me:

<a href="javascript:alert('Hello');window.focus();">test</a>
This works.  But this involves modifying the html in second frame.  Please see my previous comment.

Thanks!
Tou can do this too:

<input size=10 type="text" name="text1" onblur="window.focus();">
If the first frame html, if I add one more text box, then we cannot tab from the first textbox or click in second (have to click twice).
please donot get me wrong, I am not trying to be picky here. Since I am working on a corporate web application, I cannot afford to alter the standard user interaction.

If no one else posts a better solution, I will be happy to accept your answer.
ASKER CERTIFIED SOLUTION
Avatar of alexandermancera
alexandermancera

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you alex!!  this works perfectly for my situation...