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

Iframe question

P: n/a
I have a document lets call it a.cfm that looks like:

<iframe src="" id="test" name="test"></iframe>

<div>
<form name="myform">
... many elements here
</form>
</div>

I open up a.cfm and my js changes the src of the iframe on the fly
between a couple different scripts lets call them x.cfm and y.cfm

2 questions:

1) In x.cfm I want to access the form elements in "myform".
Of course neither of these work:
if ( self.opener.document.myform.elements[] )
if ( document.myform.elements[] )

2) In x.cfm I want to see what parent iframe I opened up.
This doesn't work:
if (document.getElementByID('test') )

Can I not point inside either document I open up?

Mike

Oct 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mike wrote:
I have a document lets call it a.cfm that looks like:

<iframe src="" id="test" name="test"></iframe>

<div>
<form name="myform">
... many elements here
</form>
</div>

I open up a.cfm and my js changes the src of the iframe on the fly
between a couple different scripts lets call them x.cfm and y.cfm

2 questions:

1) In x.cfm I want to access the form elements in "myform".
Of course neither of these work:
if ( self.opener.document.myform.elements[] )
if ( document.myform.elements[] )

2) In x.cfm I want to see what parent iframe I opened up.
This doesn't work:
if (document.getElementByID('test') )

Can I not point inside either document I open up?


Yes, you can. This thread should help:

<URL:http://groups.google.co.uk/group/comp.lang.javascript/browse_frm/thread/4fb05ca84e7ede6e/95db651f4ecd388d?q=get+the+id+of+the+iframe+that+m y+content&rnum=1&hl=en#95db651f4ecd388d>
--
Rob
Oct 18 '05 #2

P: n/a
mike said the following on 10/17/2005 8:09 PM:
I have a document lets call it a.cfm that looks like:

<iframe src="" id="test" name="test"></iframe>

<div>
<form name="myform">
... many elements here
</form>
</div>

I open up a.cfm and my js changes the src of the iframe on the fly
between a couple different scripts lets call them x.cfm and y.cfm

2 questions:

1) In x.cfm I want to access the form elements in "myform".
Of course neither of these work:
if ( self.opener.document.myform.elements[] )
if ( document.myform.elements[] )
parent.document.myform.elements[]
2) In x.cfm I want to see what parent iframe I opened up.
This doesn't work:
if (document.getElementByID('test') )
Of course not as test isn't in x.cfm

parent.document........
Can I not point inside either document I open up?


That depends on what you are calling "point insided either document".

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 18 '05 #3

P: n/a
Super guys ..... Thanks to both, works like a charm !

Oct 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.