Set focus on a form element in one frame from a different frame

A

Arvin Portlock

I can't make this work! I have two frames, a table of
contents frame on the left and a frame with lots of
form elements in it on the right.

<frameset rows="100%,*" cols="140,*">
<frame name="toc" src="toc.html">
<frame name="eadInput" src="form.html">
</frameset>

I want to click on a table of contents link on the right,
then go to the <textarea> in the frame on the left **and
set the focus in that textarea** so the user can simply
begin typing.

<a href="form.html#abstract"
onClick="javascript:
parent.eadInput.document.eadForm.ABSTRACT.focus();
parent.eadInput.focus()"
target="eadInput">

where "ABSTRACT" is the name of the <textarea> in the form
called "eadForm" in the right frame. In MSIE the focus is
switched to the right frame after clicking the link, but in
Firefox the focus stays on the left frame (which is why I
added that extra parent.eadInput.focus() to my event handler)

Can anybody tell me what I'm doing wrong?
 
K

kaeli

<a href="form.html#abstract"
onClick="javascript:
parent.eadInput.document.eadForm.ABSTRACT.focus();
parent.eadInput.focus()"
target="eadInput">

Try this for both browsers.

onClick="window.parent.frames['eadInput'].document.forms
['eadForm'].elements['ABSTRACT'].focus();"


--
 
A

Arvin Portlock

kaeli said:
enlightened us with...

Try this for both browsers.
onClick="window.parent.frames['eadInput'].document.forms
['eadForm'].elements['ABSTRACT'].focus();"

Nope, doesn't work in either browser. Everything scrolls to
where it should but no focussing.

I'm thinking the problem is somehow a conflict between the
href and the onClick. I'm thinking I'll have to put everything
in onClick and add some kind of scrollTo or location or something,
i.e., do everything--even the frame targetting--in the javascript.
I haven't tried that yet. Too many things to look up in the
Javascript book.
 
K

kaeli

Nope, doesn't work in either browser. Everything scrolls to
where it should but no focussing.

I'm thinking the problem is somehow a conflict between the
href and the onClick. I'm thinking I'll have to put everything
in onClick and add some kind of scrollTo or location or something,


Oh, of course. Silly me.
That *would* impact it.
Put a return false at the end of the onClick so the link is not followed
in browsers with script.

onClick="window.parent.frames['eadInput'].document.forms
['eadForm'].elements['ABSTRACT'].focus();return false;"



--
--
~kaeli~
If the funeral procession is at night, do folks drive with
their lights off?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
A

Arvin Portlock

kaeli said:
Nope, doesn't work in either browser. Everything scrolls to
where it should but no focussing.

I'm thinking the problem is somehow a conflict between the
href and the onClick. I'm thinking I'll have to put everything
in onClick and add some kind of scrollTo or location or something,

Oh, of course. Silly me.
That *would* impact it.
Put a return false at the end of the onClick so the link is not followed
in browsers with script.

onClick="window.parent.frames['eadInput'].document.forms
['eadForm'].elements['ABSTRACT'].focus();return false;"

Wow. And OMG too. I would have bet lots of $$$ this wouldn't
work but you were nice enough to take the time to help me so
I thought I'd give it a try and what do you know? It works.
In both browsers.

It's not 100% perfect because it doesn't scroll to absolutely
the best place (so the anchor is at the top of the screen like
normal linking behavior) but I know why that is and I can live
with it. I might try playing around with some scrolling JS to
see if I can get just what I want, though.

Thank's for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top