Log in

View Full Version : yet another DOM reference question



wyzyrd
06-09-2005, 03:41 AM
pardon the newbieness of this question, but I cant find an answer anyplace.
it OUGHT to be simple..

a file (e.g. index.php) looks basically like this:
. . .
<body>
<div id="d1">
<iframe name="f1"
src="f1.php">
</iframe>
</div>
<div id="d2">
<iframe name="f2"
src="f2.php">
</iframe>
</div>
</body>

nothing difficult so far.. emulating a frameset, basically.

what I need to discover is : how to reference the "other" iframe from inside each of the sub-documents-
e.g.from inside f2.php,
parent.frames['f1'] doesnt work
window.top.frames['f1'] doesnt work.
document.getObjectByID etc doesnt work....


I'm going nuts because this OUGHT to be simple.

Thanks in advance
Wyzyrd
<:)}
do

jscheuer1
06-09-2005, 03:55 AM
parent.f1

wyzyrd
06-09-2005, 05:19 AM
thanks, jscheuer1, I have tried it, but still no joy in Mudville....

I'm definitely confused, because, from one of the subpages, I use:
...
onclick="javascript:parent.document.getElementById('contactDetailsDiv').style.display = 'none';" ...
successfully to hide the <div> that encloses the <iframe> object.

However, when I attempt to use:
...
document.form1.target = parent.document.getElementById('contactDetailsDiv'); OR
document.form1.target = parent.contactDetailsFrame; (or any number of permutations), I get the correct form results opened in a _blank browser window. instead

(if my personal-website is not terribly slow, I'll try to reproduce the underlying mySQL tables and put a copy of the problem code directory up later tonight)

jscheuer1
06-09-2005, 05:40 AM
parent.f1 will reference the iframe named f1 from another iframe on the same page as iframe f1 but, only the iframe, not its contents. You can change its source via:

parent.f1.src='somepage.htm'

or:

parent.f1.location.replace('somepage.htm')

I've never tried to run a script on the page contained in the iframe. Maybe something like:

parent.f1.function()

I'll experiment a little.

Added later, works if function() is on the page in frame f1.

jscheuer1
06-09-2005, 06:04 AM
Using your latest example which deals with things I am not all that familiar with, I'd try:

parent.contactDetailsFrame.src=document.form1.target

I'm not really familiar with what:

document.form1.target

means. Does it represent an existing or a created on the fly page? Does it require a template?

wyzyrd
06-09-2005, 07:07 AM
what I'm attempting to do is submit POST data to the form that populates the second
iframe

the form in the first iframe normally displays a table of addresses, and uses a POST submit only to delete an item, then redisplays. (that part's easy :)

document.form1.action/ document.form1.target / and document.form1.submit()
are SUPPOSED to redirect the POST data to a different form (in a different frame)

the "alternate" form gets the POST data correctly, but I can't get it to target the output correctly

Thanks again
Wyzyrd
<:)}

jscheuer1
06-09-2005, 04:56 PM
I'm afraid you've lost me, my friend. I was suckered in by what appeared to be a simple DOM reference question. In fact, I answered that question. As I said, I am not very familiar with 'document.form1.target'. Perhaps, if you were to provide a link to a demo I could figure it out. The fact that you get a new window means it is sort of working already, we just need to get it to load in the desired iframe, right? If no 'document.form1.target' was used, would it load in the current iframe?

mwinter
06-09-2005, 06:20 PM
what I'm attempting to do is submit POST data to the form that populates the second iframeThe target property (and attribute) is a string, not an object reference. It should be the name of the target frame: f1, in this case.

Mike

jscheuer1
06-09-2005, 09:13 PM
The target property (and attribute) is a stringI think I get that, so can the OP do this?

document.form1.target='f1'

mwinter
06-09-2005, 09:30 PM
so can the OP do this?

document.form1.target='f1'If it's really not possible to include it in the form element's starting tag:


<form ... target="f1">then sure. I don't like shorthand references though, so I'd use:


document.forms.form1.target = 'f1';Mike