Results 1 to 10 of 10

Thread: yet another DOM reference question

  1. #1
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question yet another DOM reference question

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    parent.f1
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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="javascriptarent.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)

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    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.
    Last edited by jscheuer1; 06-09-2005 at 05:48 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    <}

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by wyzyrd
    what I'm attempting to do is submit POST data to the form that populates the second iframe
    The 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

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,069
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Mike
    The target property (and attribute) is a string
    I think I get that, so can the OP do this?

    document.form1.target='f1'
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    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:

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

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •