Changing the "SRC" attribute of a frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Crume

    Changing the "SRC" attribute of a frame

    Hello;

    My "index.htm" page has 3 frames (content, navigation bar, and logo).

    I set the "SRC" of the "logo" frame to a blank gif image and then want to
    change it's contents after the other two frames have been loaded by using a
    javascript statement from the "navigation " frame, as shown below:

    top.window.ccs_ logo.src = 'images/ccs_logo.gif';
    alert(top.windo w.ccs_logo.src) ;

    The "top..." is working as the "alert" shows the "SRC" has been changed, but
    the image in the "logo" frame does not change.

    I have spent several hours searching google but can't seem to find what I'm
    over-looking. (If more code, or additional details, need to be posted,
    please let me know.)

    Can anyone help me out

    TIA.

    Charles...


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


  • mscir

    #2
    Re: Changing the "SRC&qu ot; attribute of a frame

    Charles Crume wrote:[color=blue]
    > Hello;
    > My "index.htm" page has 3 frames (content, navigation bar, and logo).
    >
    > I set the "SRC" of the "logo" frame to a blank gif image and then want to
    > change it's contents after the other two frames have been loaded by using a
    > javascript statement from the "navigation " frame, as shown below:
    >
    > top.window.ccs_ logo.src = 'images/ccs_logo.gif';
    > alert(top.windo w.ccs_logo.src) ;
    >
    > The "top..." is working as the "alert" shows the "SRC" has been changed, but
    > the image in the "logo" frame does not change.
    >
    > I have spent several hours searching google but can't seem to find what I'm
    > over-looking. (If more code, or additional details, need to be posted,
    > please let me know.)
    >
    > Can anyone help me out
    > TIA.
    > Charles...[/color]

    Charles, try this:

    top.logo.docume nt.ccs_logo.src = 'images/ccs_logo.gif';

    Mike

    Comment

    • mscir

      #3
      Re: Changing the "SRC&qu ot; attribute of a frame

      mscir wrote:
      [color=blue]
      > Charles Crume wrote:
      >[color=green]
      >> Hello;
      >> My "index.htm" page has 3 frames (content, navigation bar, and logo).
      >>
      >> I set the "SRC" of the "logo" frame to a blank gif image and then
      >> want to
      >> change it's contents after the other two frames have been loaded by
      >> using a
      >> javascript statement from the "navigation " frame, as shown below:
      >>
      >> top.window.ccs_ logo.src = 'images/ccs_logo.gif';
      >> alert(top.windo w.ccs_logo.src) ;
      >>
      >> The "top..." is working as the "alert" shows the "SRC" has been
      >> changed, but
      >> the image in the "logo" frame does not change.
      >>
      >> I have spent several hours searching google but can't seem to find
      >> what I'm
      >> over-looking. (If more code, or additional details, need to be posted,
      >> please let me know.)
      >>
      >> Can anyone help me out
      >> TIA.
      >> Charles...[/color]
      >
      >
      > Charles, try this:
      >
      > top.logo.docume nt.ccs_logo.src = 'images/ccs_logo.gif';[/color]

      Correction: I read your message wrong. I think this might do what you want:

      top.logo.locati on.href='images/ccs_logo.gif';

      Comment

      • Randy Webb

        #4
        Re: Changing the "SRC&qu ot; attribute of a frame

        Charles Crume wrote:[color=blue]
        > Hello;
        >
        > My "index.htm" page has 3 frames (content, navigation bar, and logo).
        >
        > I set the "SRC" of the "logo" frame to a blank gif image and then want to
        > change it's contents after the other two frames have been loaded by using a
        > javascript statement from the "navigation " frame, as shown below:
        >
        > top.window.ccs_ logo.src = 'images/ccs_logo.gif';
        > alert(top.windo w.ccs_logo.src) ;
        >
        > The "top..." is working as the "alert" shows the "SRC" has been changed, but
        > the image in the "logo" frame does not change.[/color]

        You are not changing the source of the frame with that, you are setting
        a property of the top.window

        You don't change the SRC of a frame, you change its HREF property.

        top.window.css_ logo.href="some OtherPage.html" ;

        Thats assuming the name of the frame window is css_logo


        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Richard Cornford

          #5
          Re: Changing the "SRC&qu ot; attribute of a frame

          mscir wrote:
          <snip>[color=blue]
          > top.logo.locati on.href='images/ccs_logo.gif';[/color]

          The named/IDed frame/iframe, as a named property of the global/window
          object are not supported (or fully supported) by all browsers. However,
          all browsers that understand frames seem to make named frames available
          as named properties of the global frames collection. So, given a frame
          with the name "logo":-

          top.frames['logo'].location = ' ... ';

          - or:-

          top.frames.logo .location = ' ... ';

          - maximises cross-browser support (though some accompanying feature
          detection would still be called for).

          Richard.


          Comment

          • Charles Crume

            #6
            Re: Changing the &quot;SRC&qu ot; attribute of a frame

            Hi mscir;

            "mscir" <mscir@access4l ess.com.net.org .uk> wrote in message
            news:109r8449tn 9sc1d@corp.supe rnews.com...[color=blue]
            > mscir wrote:[/color]

            [snip]
            [color=blue]
            > Correction: I read your message wrong. I think this might do what you[/color]
            want:[color=blue]
            >
            > top.logo.locati on.href='images/ccs_logo.gif';[/color]

            Thank you -- this works great!

            I'm familiar with object oriented programming, but am new to javascript and
            still learning the object model. How did you know "top.logo.locat ion.href'
            is what I needed? And... can you tell me where I can learn this? (I've got a
            couple of books on javascript and have bookmarked over 20 pages in IE, but
            was not able to find what I needed in this instance.)

            Thanks again for your help.

            Charles...


            Charles...


            ---
            Outgoing mail is certified Virus Free.
            Checked by AVG anti-virus system (http://www.grisoft.com).
            Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


            Comment

            • Charles Crume

              #7
              Re: Changing the &quot;SRC&qu ot; attribute of a frame

              Hi Richard;

              "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
              news:c7k90p$29t $1$8302bc10@new s.demon.co.uk.. .

              [snip]
              [color=blue]
              > The named/IDed frame/iframe, as a named property of the global/window
              > object are not supported (or fully supported) by all browsers. However,
              > all browsers that understand frames seem to make named frames available
              > as named properties of the global frames collection. So, given a frame
              > with the name "logo":-
              >
              > top.frames['logo'].location = ' ... ';
              > top.frames.logo .location = ' ... ';
              >
              > - maximises cross-browser support (though some accompanying feature
              > detection would still be called for).[/color]

              Thank you -- your suggestions work great also!

              I'm familiar with object oriented programming, but am new to javascript and
              still learning the object model. How did you know "top.frames ...' is what I
              needed? Can you tell me where I can read more about "named/IDed
              frame/iframe, as a named property..."?

              Thanks again for your help.

              Charles...


              ---
              Outgoing mail is certified Virus Free.
              Checked by AVG anti-virus system (http://www.grisoft.com).
              Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


              Comment

              • mscir

                #8
                Re: Changing the &quot;SRC&qu ot; attribute of a frame

                Charles Crume wrote:[color=blue]
                > Hi mscir;
                > "mscir" wrote in message[color=green]
                >>mscir wrote:[/color]
                > [snip][color=green]
                >>Correction: I read your message wrong. I think this might do what you[/color]
                > want: top.logo.locati on.href='images/ccs_logo.gif';
                >
                > Thank you -- this works great!
                >
                > I'm familiar with object oriented programming, but am new to javascript and
                > still learning the object model. How did you know "top.logo.locat ion.href'
                > is what I needed? And... can you tell me where I can learn this? (I've got a
                > couple of books on javascript and have bookmarked over 20 pages in IE, but
                > was not able to find what I needed in this instance.)
                >
                > Thanks again for your help.
                > Charles...[/color]

                Hi Charles,

                Sorry about my first incorrect post. I read about 'top' here:



                This talks about it too (found w/google while finding first site):

                Learn to write JavaScript that works across HTML frames using frame tree navigation with top, parent, and child references.


                Glad it worked,
                Mike

                Comment

                • Charles Crume

                  #9
                  Re: Changing the &quot;SRC&qu ot; attribute of a frame

                  Hi Randy;

                  "Randy Webb" <hikksnotathome @aol.com> wrote in message
                  news:8KydnRplEP KrPgDdRVn-tA@comcast.com. ..

                  [snip]
                  [color=blue]
                  > You are not changing the source of the frame with that, you are setting
                  > a property of the top.window
                  >
                  > You don't change the SRC of a frame, you change its HREF property.[/color]

                  OK. Can you recommend a source of info (book, web site, etc.) where I can
                  read up on this (I thought I was changing the correct property -- i.e., it's
                  the frame's "SRC" property that specifies the page/img to use).

                  [color=blue]
                  > top.window.css_ logo.href="some OtherPage.html" ;[/color]

                  I get "Error: 'top.window.ccs _logo' is null or not an object when I use
                  this. As I am not sure of the object heirarchy (just yet anyways, but I'm
                  working on it :-), I'm not sure what to change here. "ccs_logo" is the frame
                  name, but it is in a "framset" that is within a "framset" as shown below:

                  -------------------------------
                  <frameset name="xxx" cols="0,*" border="0" frameborder="ye s"
                  borderwidth="12 " bordercolor="00 00FF" framespacing="0 ">
                  <frame src="intro.shtm l" name="content_a rea" scrolling="yes" border="0"
                  frameborder="0" noresize>
                  <frameset name="yyy" rows="*,0" border="0" frameborder="no "
                  bordercolor="FF 0000" framespacing="0 ">
                  <frame src="images/nil.gif" name="ccs_logo" scrolling="no"
                  border="0" frameborder="0" noresize>
                  <frame src="navigate.h tm" name="navigate" scrolling="yes" border="0"
                  frameborder="0" >
                  </frameset>
                  <noframes>
                  <body><p>This page uses frames, but your browser does not support
                  them.</p>
                  </body>
                  </noframes>
                  </frameset>
                  -------------------------------

                  Thanks again for your help.

                  Charles...


                  ---
                  Outgoing mail is certified Virus Free.
                  Checked by AVG anti-virus system (http://www.grisoft.com).
                  Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


                  Comment

                  • Charles Crume

                    #10
                    Re: Changing the &quot;SRC&qu ot; attribute of a frame

                    Hi mscir;

                    "mscir" <mscir@access4l ess.com.net.org .uk> wrote in message
                    news:109rirhk5e 8jdad@corp.supe rnews.com...

                    [snip]
                    [color=blue]
                    > Sorry about my first incorrect post. I read about 'top' here:[/color]

                    No problem -- I am grateful for your help!!

                    [color=blue]
                    > http://www.quirksmode.org/js/frameintro.html
                    > This talks about it too (found w/google while finding first site):
                    > http://www.yourhtmlsource.com/javasc...ingframes.html[/color]

                    Thanks, I've bookmarked both pages (I even looked at the first page during
                    my search and had already bookmarked it). I think I understand the "frame
                    tree" (at least a little), but am unaware of the various "normal properties"
                    as mentioned in:

                    -------------
                    "As you see, you first walk to the correct frame, then you access normal
                    properties like location.href or document.title and read them out or change
                    them."
                    -------------

                    Do you know where I can find some documentation on the so called "normal
                    properties"?? (The site mentions them, but does not give a link to more
                    info -- unless I missed it.)

                    I searched and searched google using variations of "javascript frame
                    properties" and either did not find them are didn't realize I had and kept
                    on looking.

                    Charles...




                    ---
                    Outgoing mail is certified Virus Free.
                    Checked by AVG anti-virus system (http://www.grisoft.com).
                    Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


                    Comment

                    • mscir

                      #11
                      Re: Changing the &quot;SRC&qu ot; attribute of a frame

                      Charles Crume wrote:
                      <snip>[color=blue]
                      >
                      > Thanks, I've bookmarked both pages (I even looked at the first page during
                      > my search and had already bookmarked it). I think I understand the "frame
                      > tree" (at least a little), but am unaware of the various "normal properties"
                      > as mentioned in:
                      > -------------
                      > "As you see, you first walk to the correct frame, then you access normal
                      > properties like location.href or document.title and read them out or change
                      > them."
                      > -------------
                      > Do you know where I can find some documentation on the so called "normal
                      > properties"?? (The site mentions them, but does not give a link to more
                      > info -- unless I missed it.)[/color]
                      <snip>

                      I think a good place to start might be a frames tutorial. You can find
                      lots of them with google. I found this searching for 'frame tutorial
                      html', I think this one looks decent after a quick look, maybe other
                      people know of better web pages dealing with this subject:



                      Mike

                      Comment

                      • Charles Crume

                        #12
                        Re: Changing the &quot;SRC&qu ot; attribute of a frame

                        Hi Mike;

                        "mscir" <mscir@access4l ess.com.net.org .uk> wrote in message
                        news:109rlk8osq 4mdbc@corp.supe rnews.com...

                        [snip]
                        [color=blue]
                        > I think a good place to start might be a frames tutorial. You can find
                        > lots of them with google. I found this searching for 'frame tutorial
                        > html'
                        > http://www.idocs.com/tags/frames/frames.html[/color]

                        Yes, I found a bunch of them too -- and this one looks real good.

                        However, and perhaps I have not articulated my difficulty in understanding
                        this adequately, but I do not see any info on the "location.h ref" property
                        that you used in:

                        top.logo.locati on.href='images/ccs_logo.gif';

                        to help me get my problem solved.

                        I clicked on both the <FRAMESET ...> and <FRAME ...> links and neither has a
                        "location" or "href" property!! This is what's stumping/confusing me :-(

                        Where does "location" come from? Where does "href" come from? This site, as
                        well as all the others I've looked at, show the "SRC" attribute (property??)
                        to be what holds the URL.

                        Am I missing something *real* obvious here?

                        Thanks.

                        Charles...



                        ---
                        Outgoing mail is certified Virus Free.
                        Checked by AVG anti-virus system (http://www.grisoft.com).
                        Version: 6.0.674 / Virus Database: 436 - Release Date: 5/2/04


                        Comment

                        • Richard Cornford

                          #13
                          Re: Changing the &quot;SRC&qu ot; attribute of a frame

                          Charles Crume wrote:
                          <snip>[color=blue]
                          > I'm familiar with object oriented programming, but am new to
                          > javascript and still learning the object model.[/color]

                          It isn't anything like as simple as "the object model" as only a limited
                          part of the browser object model is standardised, browsers do not
                          necessarily fully (or correctly) implement the standards that do exist,
                          and some provide additional features.
                          [color=blue]
                          > How did you know "top.frames ...' is what I needed?[/color]

                          Even with the diversity in browser DOMs there are common features and
                          the - frames - collection on the global object is common to browsers
                          that understand what a frame is.

                          But to be honest I don't think - top.frames - is what you want. I
                          think - parent.frames - is actually what you are after. In a frame
                          within a frameset - top - and - parent - refer to the same object, but -
                          parent - is a reference to the frame containing the current
                          window/global object, while - top - is a reference to the topmost (or
                          outermost) frameset page. If your frameset page is displayed in a frame
                          of another frameset the - top - reference will refer to the wrong
                          object, while the - parent - reference will still refer to the
                          immediately containing frameset's global/window object.

                          In a single HTML page (outside a frameset) - top, parent, window and
                          self - all refer to the same (only) global/window object.

                          I didn't mention that in my previous post because I was primarily
                          interested in introducing Mike to the benefits for cross-browser
                          scripting in using the - frames - collection over assuming that a
                          named/IDed frame would be available as a property of the global/window
                          object. On the (rare) occasions when browser scripting allows a "one
                          method suites all" (at least all that understand frames in the first
                          place) solution, it saves a lot of unnecessary grief to know what that
                          method is as soon as possible.

                          But over all I tend towards the often-expressed opinion that frames are
                          more trouble than they are worth anyway, so the question becomes
                          somewhat academic.
                          [color=blue]
                          > Can you tell me where I can read more about
                          > "named/IDed frame/iframe, as a named property..."?[/color]
                          <snip>

                          Formal documentation for browser object models has always been a
                          problem. Microsoft and Mozilla document their browser's DOMs (though the
                          Mozilla documentation could do with an update sometime soon) and
                          Netscape still make documentation for Netscape 4 available (as the
                          JavaScript 1.3 client-side reference). And the W3C publishes the DOM
                          standard that are being adopted by web browsers, though they are mostly
                          concerned exclusively with the document and do not have much to say
                          about the parts of the browser object model outside of the document.

                          Apart from that, detailed browser object model documentation is fairly
                          hard to find. Opera's, for example, mostly refers back to the W3C
                          standards, and doesn't mention most of the features of IE browsers that
                          it reproduces.

                          (The group's FAQ includes URLs for the documentation that has been
                          identified).

                          Personally, I like to find out from the browsers themselves exactly what
                          their object models contain. They aren't always that forthcoming but I
                          have published some listings of complete example browser object models
                          at:-

                          <URL: http://www.litotes.demon.co.uk/dom_root.html >

                          (They are one html page listing properties (name, current value and
                          type) per object, with properties that refer to other object acting as
                          links to the pages that list the properties of those objects. Providing
                          structure and content for the object models listed. (avoid the
                          IceBrowser 5 listing at first as it is a bit of an oddity, interesting
                          in demonstrating the potential diversity but not very representative of
                          browsers in general))

                          Richard.


                          Comment

                          • Lasse Reichstein Nielsen

                            #14
                            Re: Changing the &quot;SRC&qu ot; attribute of a frame

                            "Richard Cornford" <Richard@litote s.demon.co.uk> writes:
                            [color=blue]
                            > Apart from that, detailed browser object model documentation is fairly
                            > hard to find. Opera's, for example, mostly refers back to the W3C
                            > standards, and doesn't mention most of the features of IE browsers that
                            > it reproduces.[/color]

                            I think they *mention* them, but one would need to look up the Microsoft
                            documentation to see what they actually do :)
                            <URL:http://www.opera.com/docs/specs/#jscript>
                            [color=blue]
                            > <URL: http://www.litotes.demon.co.uk/dom_root.html >[/color]

                            Kewl!

                            /L
                            --
                            Lasse Reichstein Nielsen - lrn@hotpop.com
                            DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                            'Faith without judgement merely degrades the spirit divine.'

                            Comment

                            • mscir

                              #15
                              Re: Changing the &quot;SRC&qu ot; attribute of a frame

                              Richard Cornford wrote:[color=blue]
                              > mscir wrote:
                              > <snip>[color=green]
                              >>top.logo.loca tion.href='imag es/ccs_logo.gif';[/color]
                              >
                              > The named/IDed frame/iframe, as a named property of the global/window
                              > object are not supported (or fully supported) by all browsers. However,
                              > all browsers that understand frames seem to make named frames available
                              > as named properties of the global frames collection. So, given a frame
                              > with the name "logo":-
                              >
                              > top.frames['logo'].location = ' ... ';
                              > - or:-
                              > top.frames.logo .location = ' ... ';
                              >
                              > - maximises cross-browser support (though some accompanying feature
                              > detection would still be called for).
                              >
                              > Richard.[/color]

                              Richard,

                              Do you know of any sites where I can read about browser support for
                              these different frame methods?

                              Mike

                              Comment

                              Working...