How to make Javascript update IFRAME SRC?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Anderson

    How to make Javascript update IFRAME SRC?

    How can I make an onchange event update the src for an IFRAME? I would like
    to do it without reloading the page, is this possible?

    Dave


  • Martin Honnen

    #2
    Re: How to make Javascript update IFRAME SRC?



    Dave Anderson wrote:
    [color=blue]
    > How can I make an onchange event update the src for an IFRAME? I would like
    > to do it without reloading the page, is this possible?[/color]

    <iframe name="iframeNam e" src="whatever.h tml"></iframe>

    <select onchange="if (window.frames && window.frames.i frameName) {
    window.frames.i frameName.locat ion.href =
    this.options[this.selectedIn dex].value;
    }">

    --

    Martin Honnen


    Comment

    • Cenekemoi

      #3
      Re: How to make Javascript update IFRAME SRC?

      Bonjour à Martin Honnen <mahotrash@yaho o.de> qui nous a écrit :[color=blue]
      > Dave Anderson wrote:
      >[color=green]
      >> How can I make an onchange event update the src for an IFRAME? I
      >> would like to do it without reloading the page, is this possible?[/color]
      >
      > <iframe name="iframeNam e" src="whatever.h tml"></iframe>
      >
      > <select onchange="if (window.frames && window.frames.i frameName) {
      > window.frames.i frameName.locat ion.href =
      > this.options[this.selectedIn dex].value;
      > }">[/color]

      or:
      <iframe id="iframeId" src="whatever.h tml"></iframe>

      <select onchange="if (document.getEl ementById) {
      document.getEle mentById('ifram eId').src =
      this.options[this.selectedIn dex].value;
      }">

      --
      Cordialement, Thierry ;-)

      Comment

      • Richard Cornford

        #4
        Re: How to make Javascript update IFRAME SRC?

        "Cenekemoi" <tbaudessonENLE VER@harrysoftwa re.ENVELERcom> wrote in
        message news:bv88hj$47f $1@news-reader4.wanadoo .fr...
        <snip>[color=blue][color=green][color=darkred]
        >>> How can I make an onchange event update the src for an IFRAME? I
        >>> would like to do it without reloading the page, is this possible?[/color]
        >>
        >> <iframe name="iframeNam e" src="whatever.h tml"></iframe>
        >>
        >> <select onchange="if (window.frames && window.frames.i frameName) {
        >> window.frames.i frameName.locat ion.href =
        >> this.options[this.selectedIn dex].value;
        >> }">[/color]
        >
        >or:
        > <iframe id="iframeId" src="whatever.h tml"></iframe>
        >
        > <select onchange="if (document.getEl ementById) {
        > document.getEle mentById('ifram eId').src =
        > this.options[this.selectedIn dex].value;
        > }">[/color]

        No, Martin's formulation is the most cross-browsers code for the task
        and will work on significantly more browsers than attempting to re-set
        the SRC of an IDed IFRAME by assigning to its src property.

        Richard.


        Comment

        Working...