dynamic src of IFRAME

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dkode8@gmail.com

    #1

    dynamic src of IFRAME

    I am ripping my hair out trying to set the src (location.href) of an
    IFRAME that i show once a user clicks on a certain link:

    function editTimeEntry(t imeEntryID, dayID, e) {
    var x = e.clientX;
    var y = e.clientY;
    ew = frames['editPop'];
    eF = getObj('editPop ID');
    eF.style.left = x + 10;
    eF.style.top = y + 10;
    window.top.fram es['editPopID'].location.href =
    "controls/editPopup.aspx? id=" + timeEntryID + "&did=" + dayID;
    ShowFrame();
    }

    function ShowFrame() {
    if (eF.style.displ ay=="none") {
    eF.style.displa y="black"; // FF Drawing bug
    }
    eF.style.visibi lity="visible";
    alert("Location :" + document.frames['editPop'].location.href) ;
    }

    When the IFRAME is displayed it just shows about:blank and not the
    location.href I set for it. After the first time, i click on the same
    link and it shows me the correct address in the alert box in
    ShowFrame(), but the iframe remains blank. can anyone point me to the
    right documentation or help me out? It would be greatly appreciated.
    Thank you.

    Sean

  • RobB

    #2
    Re: dynamic src of IFRAME

    dko...@gmail.co m wrote:[color=blue]
    > I am ripping my hair out trying to set the src (location.href) of an
    > IFRAME that i show once a user clicks on a certain link:
    >
    > function editTimeEntry(t imeEntryID, dayID, e) {
    > var x = e.clientX;
    > var y = e.clientY;
    > ew = frames['editPop'];
    > eF = getObj('editPop ID');
    > eF.style.left = x + 10;
    > eF.style.top = y + 10;
    > window.top.fram es['editPopID'].location.href =
    > "controls/editPopup.aspx? id=" + timeEntryID + "&did=" + dayID;
    > ShowFrame();
    > }
    >
    > function ShowFrame() {
    > if (eF.style.displ ay=="none") {
    > eF.style.displa y="black"; // FF Drawing bug
    > }
    > eF.style.visibi lity="visible";
    > alert("Location :" + document.frames['editPop'].location.href) ;
    > }
    >
    > When the IFRAME is displayed it just shows about:blank and not the
    > location.href I set for it. After the first time, i click on the same
    > link and it shows me the correct address in the alert box in
    > ShowFrame(), but the iframe remains blank. can anyone point me to the
    > right documentation or help me out? It would be greatly appreciated.
    > Thank you.
    >
    > Sean[/color]

    Didn't post your HTML -which leaves people to guess what all those
    identifiers correspond to. You're dealing with *two* objects there: a
    frame (window) object, with its Location object (location property),
    and an element object, which sets the iframe src via its - erm - src
    property. Unclear why all the duplication...a nyway, the frame object is
    referenced via the frame name, not its id as the element object is.

    window.top.fram es['editPop'].location.href = ....
    (or ew.location.hre f = ....)

    <iframe name="editPop". ..>

    Typo?

    eF.style.displa y="black" <-----

    Comment

    • Richard Cornford

      #3
      Re: dynamic src of IFRAME

      dkode8@gmail.co m wrote:
      <snip>[color=blue]
      > window.top.fram es['editPopID'].location.href =
      > "controls/editPopup.aspx? id=" + timeEntryID + "&did=" + dayID;[/color]
      <snip>[color=blue]
      > ... just shows about:blank ...[/color]
      <snip>

      All else aside, if you have an IFRAME with "about:blan k" as its SRC,
      when you assign a relative URL to the corresponding location object what
      are you expecting that URL to be relative to?

      Richard.


      Comment

      • dkode8@gmail.com

        #4
        Re: dynamic src of IFRAME

        I have tried everything with no luck. It works perfectly in FireFox,
        but it DOES NOT work in IE. I have tried the following:

        window.frames["editPop"].location = "http://website/address/here"
        top.frames["editPop"].location = "http://website/address/here"
        document.frames["editPop"].location = "http://website/address/here"
        document.top.fr ames["editPop"].location = "http://website/address/here"
        window.top.fram es["editPop"].location = "http://website/address/here"

        Does anyone know how I can get this to work? It's really aggravating.

        Comment

        • RobB

          #5
          Re: dynamic src of IFRAME

          dko...@gmail.co m wrote:[color=blue]
          > I have tried everything with no luck. It works perfectly in FireFox,
          > but it DOES NOT work in IE. I have tried the following:
          >
          > window.frames["editPop"].location = "http://website/address/here"
          > top.frames["editPop"].location = "http://website/address/here"
          > document.frames["editPop"].location = "http://website/address/here"
          > document.top.fr ames["editPop"].location =[/color]
          "http://website/address/here"[color=blue]
          > window.top.fram es["editPop"].location = "http://website/address/here"
          >
          > Does anyone know how I can get this to work? It's really aggravating.[/color]

          How about...

          window.self.top .parent.documen t.frames["editPop"].location.href. com

          Seriously...not to beat a dead iframe...

          RobB wrote:
          [color=blue][color=green]
          >> Didn't post your HTML -which leaves people
          >> to guess what all those identifiers correspond to.[/color][/color]

          Your HTML here is the architectural blueprint to the structure of your
          document(s). Better to analyze it than just string references together
          and pray.

          Comment

          • Csaba Gabor

            #6
            Re: dynamic src of IFRAME

            dkode8@gmail.co m wrote:[color=blue]
            > window.top.fram es['editPopID'].location.href =
            > "controls/editPopup.aspx? id=" + timeEntryID + "&did=" + dayID;[/color]

            Have you tried?
            top.document.ge tElementById('e ditPopID').src = "http://yourPageHere";

            Csaba Gabor from Vienna

            Comment

            • dkode8@gmail.com

              #7
              Re: dynamic src of IFRAME

              HA!

              top.document.ge tElementyById(' editPopID').src worked.

              what a task! thank you very much for your help!

              Comment

              • Richard Cornford

                #8
                Re: dynamic src of IFRAME

                Csaba Gabor wrote:[color=blue]
                > dkode8@gmail.co m wrote:[color=green]
                >> window.top.fram es['editPopID'].location.href =
                >> "controls/editPopup.aspx? id=" + timeEntryID +
                >> "&did=" + dayID;[/color]
                >
                > Have you tried?
                > top.document.ge tElementById('e ditPopID').src =
                > "http://yourPageHere";[/color]

                It seems a bit unfair to take someone who is probably making a trivial
                error (or suffering a minor misconception) in their use of a reliable
                cross-browser technique for navigating a frame and sending them off with
                an alternative that is significantly less well supported and should not
                be expected to work at all according to the applicable standard.

                Richard.


                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: dynamic src of IFRAME

                  Richard Cornford wrote:
                  [color=blue]
                  > Csaba Gabor wrote:[color=green]
                  >> dkode8@gmail.co m wrote:[color=darkred]
                  >>> window.top.fram es['editPopID'].location.href =
                  >>> "controls/editPopup.aspx? id=" + timeEntryID +
                  >>> "&did=" + dayID;[/color]
                  >>
                  >> Have you tried?
                  >> top.document.ge tElementById('e ditPopID').src =
                  >> "http://yourPageHere";[/color]
                  >
                  > It seems a bit unfair to take someone who is probably making a trivial
                  > error (or suffering a minor misconception) in their use of a reliable
                  > cross-browser technique for navigating a frame and sending them off with
                  > an alternative that is significantly less well supported[/color]

                  Full ACK
                  [color=blue]
                  > and should not be expected to work at all according to the applicable
                  > standard.[/color]

                  NAK. According to the "applicable standard" (DOM Level 2+), DOM Level 0
                  references not specified therein should not work at all in HTML user
                  agents, so the first version should ultimately fail. However, it does
                  usually work and it does not fail. And since both this is the case and
                  recent UAs implement interfaces of the W3C DOM, I would consider the
                  second version somewhat nearer to the "standards" than the first.
                  (Although I would not recommend it at the moment for the reasons given
                  above.)

                  Consider this: (window.)top is proprietary but widely supported (DOM Level
                  0), and if the Window object referred to by it implemented DOM Level 2
                  Views it had a `document' property, and if the object referred to by it
                  would implement the Document interface (interestingly, e.g. the Gecko DOM
                  implementation yields an object with the prototype HTMLDocument while this
                  is an identifier of an interface inheriting from Document in DOM Level 2
                  HTML) and so it would have a getElementById( ) method which application
                  with the above argument would return an object implementing the
                  HTMLIFrameEleme nt interface (which e.g. the Gecko DOM provides) which
                  would have a `src' property that is not read-only.


                  PointedEars

                  Comment

                  • Richard Cornford

                    #10
                    Re: dynamic src of IFRAME

                    Thomas 'PointedEars' Lahn wrote:[color=blue]
                    > Richard Cornford wrote:[/color]
                    <snip>[color=blue][color=green]
                    >> and should not be expected to work at all according to
                    >> the applicable standard.[/color][/color]
                    <snip>[color=blue]
                    > ... HTMLIFrameEleme nt interface (which e.g.
                    > the Gecko DOM provides) which would have a
                    > `src' property that is not read-only.[/color]

                    <quote cite="W3C Level 2 HTML DOM; HTMLIFrameEleme nt interface">
                    src - of type DOMString
                    A URI [IETF RFC 2396] designating the initial frame contents. See the
                    src attribute definition in HTML 4.01.
                    </quote>

                    It may not be read-only but what does it mean to assign a URI to "the
                    initial frame contents"? Now if the spec said "current frame contents"
                    then an assignment to - src - might be expected to result in navigation,
                    but assigning to the initial content would do what? A frame can only
                    have one "initial frame contents".

                    As a means of navigation, assigning a value to the - src - property of
                    an IFRAME element should not be expected to work, according to the
                    applicable standard.

                    Richard.


                    Comment

                    • Thomas 'PointedEars' Lahn

                      #11
                      Re: dynamic src of IFRAME

                      Richard Cornford wrote:
                      [color=blue]
                      > Thomas 'PointedEars' Lahn wrote:[color=green]
                      >> Richard Cornford wrote:[/color]
                      > <snip>[color=green][color=darkred]
                      >>> and should not be expected to work at all according to
                      >>> the applicable standard.[/color][/color]
                      > <snip>[color=green]
                      >> ... HTMLIFrameEleme nt interface (which e.g.
                      >> the Gecko DOM provides) which would have a
                      >> `src' property that is not read-only.[/color]
                      >
                      > <quote cite="W3C Level 2 HTML DOM; HTMLIFrameEleme nt interface">
                      > src - of type DOMString
                      > A URI [IETF RFC 2396] designating the initial frame contents.[/color]
                      ^^^^^^^[color=blue]
                      > See the src attribute definition in HTML 4.01.
                      > </quote>
                      > [...][/color]

                      Point taken, thanks. Should be changed to either `current'
                      or read-only, though. W3C member anyone? ;-)


                      PointedEars
                      --
                      What one man can invent another can discover.
                      -- Sherlock Holmes in Sir A.C. Doyle's
                      "The Adventure of the Dancing Men"

                      Comment

                      Working...