simple iframe, calling with innerHTML - what am i doing wrong here?

Discussion in 'HTML' started by Ragnorack67@hotmail.com, Mar 2, 2005.

  1. Guest

    ....[something.htm]

    <div id=work>hello</div>


    ....[somethingelse.htm]

    <IFRAME id="thisframe" src="./something.htm"></IFRAME>

    <script>
    document.frames("thisframe").getElementById("work").innerHTML =
    "goodbye"
    </script>

    Thank you
     
    , Mar 2, 2005
    #1
    1. Advertising

  2. Bert Guest

    <> schreef in bericht
    news:...
    > ...[something.htm]
    >
    > <div id=work>hello</div>
    >
    >
    > ...[somethingelse.htm]
    >
    > <IFRAME id="thisframe" src="./something.htm"></IFRAME>
    >
    > <script>
    > document.frames("thisframe").getElementById("work").innerHTML =
    > "goodbye"
    > </script>
    >
    > Thank you
    >


    change to:
    document.frames("thisframe").getElementById("work").body.innerHTML =

    grt Bert
     
    Bert, Mar 3, 2005
    #2
    1. Advertising

  3. Bert Guest

    "Bert" <> schreef in bericht
    news:STsVd.254474$...
    >
    > <> schreef in bericht
    > news:...
    >> ...[something.htm]
    >>
    >> <div id=work>hello</div>
    >>
    >>
    >> ...[somethingelse.htm]
    >>
    >> <IFRAME id="thisframe" src="./something.htm"></IFRAME>
    >>
    >> <script>
    >> document.frames("thisframe").getElementById("work").innerHTML =
    >> "goodbye"
    >> </script>
    >>
    >> Thank you
    >>

    >
    > change to:
    > document.frames("thisframe").getElementById("work").body.innerHTML =
    >
    > grt Bert
    >


    sorry, makes nog sense...
     
    Bert, Mar 3, 2005
    #3
  4. Bert Guest

    <> schreef in bericht
    news:...
    > ...[something.htm]
    >
    > <div id=work>hello</div>
    >
    >
    > ...[somethingelse.htm]
    >
    > <IFRAME id="thisframe" src="./something.htm"></IFRAME>
    >
    > <script>
    > document.frames("thisframe").getElementById("work").innerHTML =
    > "goodbye"
    > </script>
    >
    > Thank you
    >


    document.frames("thisframe").document.getElementById("work").innerHTML =
    "goodbye";

    that might be better...
     
    Bert, Mar 3, 2005
    #4
  5. Guest

    Hmm, tried both and still can't get it to work. I'm yanking my hair out
    with this one. Nothing seems to work! Have you tested it out?
     
    , Mar 3, 2005
    #5
  6. Guest

    Hmm, tried both and still can't get it to work. I'm yanking my hair out

    with this one. Nothing seems to work! Any ideas?
     
    , Mar 3, 2005
    #6
  7. Bert Guest

    here's the source I tested it with:




    <html>

    <script>
    function test()
    {

    document.frames("thisframe").document.getElementById("work").innerHTML =
    "goodbye";

    }
    </script>

    <body onload = "test()">


    <IFRAME id="thisframe" src="./something.htm"></IFRAME>

    </body>
    </html>
     
    Bert, Mar 3, 2005
    #7
  8. Guest

    Interesting. Why does it error out if you remove test(); from body
    onload? Anyway to make it a seperate call function, like <script>
    test(); </script> somewhere else?
     
    , Mar 3, 2005
    #8
  9. Guest

    Thank you -- works perfectly... Have a great weekend! :)))

    Sincerely --

    Alex
     
    , Mar 3, 2005
    #9
  10. DU Guest

    Re: simple iframe, calling with innerHTML

    Followup-to: comp.lang.javascript only

    wrote:
    > ...[something.htm]
    >
    > <div id=work>hello</div>
    >
    >
    > ...[somethingelse.htm]
    >
    > <IFRAME id="thisframe" src="./something.htm"></IFRAME>



    <iframe name="thisframe" src="./something.htm"></iframe>


    >
    > <script>
    > document.frames("thisframe").getElementById("work").innerHTML =


    - frames collection are a property of the window object, not of the
    document.
    - you can access a single frame within the frames collection with
    frames["FrameName"] or with frames.FrameName but not with
    frames("IframeId"). You're confused in the correct way to access a frame.
    - when accessing a frame, the returned object is a window object, not a
    document.
    - contentDocument is a property of the iframe object which can return a
    reference to the document contained in the iframe. So assuming:

    <iframe id="idIframe" ...></iframe>

    then you can access such iframed document like this:

    document.getElementById("idIframe").contentDocument


    > "goodbye"
    > </script>
    >
    > Thank you
    >



    <head>
    ....
    <script type="text/javascript">
    function PopulateIframe()
    {
    var IframedDocumentBody = frames["thisframe"].document.body;
    var FirstParg = document.createElement("p");
    FirstParg.appendChild(document.createTextNode("goodbye"));
    IframedDocumentBody.appendChild(FirstParg);
    }
    </script>
    </head>

    <body onload="PopulateIframe();">
    ....

    Not tested but should work in Mozilla-based browsers.

    DU
    Followup-to: comp.lang.javascript only
    --
    The site said to use Internet Explorer 5 or better... so I switched to
    Mozilla 1.7.5 :)
     
    DU, Mar 4, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    1
    Views:
    439
  2. Jeremy Watts

    what am i doing wrong here?

    Jeremy Watts, Jun 4, 2005, in forum: Java
    Replies:
    12
    Views:
    583
    Jeremy Watts
    Jun 5, 2005
  3. =?ISO-8859-1?Q?Gerhard_H=E4ring?=

    Re: What am I doing wrong here?

    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jun 30, 2003, in forum: Python
    Replies:
    1
    Views:
    723
    Bengt Richter
    Jun 30, 2003
  4. Replies:
    9
    Views:
    126
  5. Paul
    Replies:
    16
    Views:
    211
    Jayme Pechan
    Aug 31, 2005
Loading...

Share This Page