[thelist] JAVASCRIPT and IFRAMEs [solved i think]

Tom Dell'Aringa pixelmech at yahoo.com
Mon Jul 29 16:09:01 CDT 2002


I believe Jeff got me in the right direction here.

With my little document set I made up to mimic yours, turns out the
iframe document itself is the opener. (Using opener.location.href to
find this out, kudos to jeff.)

So, I just did:

var x = window.opener.document.getElementById("sometext").value;

where "sometext" was a FIELD in my FORM (which is what you want
right?) and the value came over perfectly.

So as long as the link that is opening the popup is INSIDE the iframe
(and i thought you said it was) the opener is the Iframe - not the
document that holds it.

HTH.

Tom
--- ".jeff" <jeff at members.evolt.org> wrote:
> phil,
>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > From: Phil Essing
> >
> [...] on my main HTML page I have an IFRAME that loads
> > another HTML document.  Within this second document
> > (contained in the IFRAME) I have an SSI which contains
> > a form.  In this form there is a link which opens a
> > popup calendar, with each date hyperlinked.  When the
> > user clicks a date, the value needs to be passed to the
> > appropriate form fields.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
> sounds easy enough.  if you're not checking for the opener from the
> document in the iframe at the time of creation of the popup, you
> should be and if it doesn't exist setting it to self.
>
> if(!popupWin.opener)
>   popupWin.opener = self;
>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > Trying to pass the values back to the form will not work
> > using <a href="#" onClick="self.opener.document.formname
> >.fieldname.value">day</a>.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
> first of all, fix the way you're using the <a> tag.  do *not* use a
> hash (#) as the value of the href attribute.
>
> Links & JavaScript Living Together in Harmony
> http://evolt.org/article/thelist/17/20938/
>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > The code works outside of the IFRAME, because
> > self.opener is apparent.  Within the IFRAME, however,
> > I get the following error: "self.opener.document.
> > formname.fieldname.value" is not an object.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
> no matter if the window was opened from a document at the top
> level, from a document in an iframe, or from a document in a
> frameset, the opener should *always* be apparent to the popup.  if
> i were you i'd consider working out where the object reference
> breaks.
>
> try alerting each step of the way:
>
> alert(self.opener);
> alert(self.opener.location.href);
> alert(self.opener.document);
> alert(self.opener.document.forms.length);
> alert(self.opener.document.formname);
> alert(self.opener.document.formname.elements.length);
> alert(self.opener.document.formname.fieldname);
> alert(self.opener.document.formname.fieldname.value);
>
> if you could make this available online somewhere it'd be easier to
> debug.
>
> thanks,
>
> .jeff
>
> http://evolt.org/
> jeff at members.evolt.org
> http://members.evolt.org/jeff/
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



More information about the thelist mailing list