By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <cc**********@agate.berkeley.edu>, ap********@hotmail.com
enlightened us with...

<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();"
--
--
~kaeli~
Doing my part to piss off the Religious Right.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

P: n/a
>kaeli wrote:
In article , ap********@hotmail.com
enlightened us with...
<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();"


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.
Jul 23 '05 #3

P: n/a
In article <cc***********@agate.berkeley.edu>, ap********@hotmail.com
enlightened us with...

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

Jul 23 '05 #4

P: n/a
kaeli wrote:
In article , ap********@hotmail.com
enlightened us with...
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!

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.