HELP: Changing ilayer src from a href link...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brandon Hoppe

    HELP: Changing ilayer src from a href link...


    I'm trying to change the src of an ilayer in the parent document from a link inside the
    ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is
    for Netscape 4 only.


    For example, here is the main page:

    <html>
    <head>
    <script type="text/javascript">
    function updateILayer(ob j) {
    parent.document .layers["layer1"].src = obj.href;
    }
    </script>
    </head>

    <body>
    <ilayer name="layer1" id="layer1" src="home.htm">
    </ilayer>
    </body>
    </html>

    And here's the home.htm src:

    <html>
    <head>
    </head>

    <body>
    Click this link to go to test page:
    <a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>
    </body>
    </html>

    And here's the test.htm src:

    <html>
    <head>
    </head>

    <body>
    Click this link to go to home page:
    <a onClick="parent .updateILayer(t his);" href="home.htm" >home</a>
    </body>
    </html>



  • Brandon Hoppe

    #2
    Re: HELP: Changing ilayer src from a href link...

    Well, to keep it from crashing when you click on the link, I've change the function as such:

    function updateILayer(ob j) {
    eval("parent.do cument.layer1.s rc=" + obj.href);
    }

    But it still doesn't work. It just goes to that link and doesn't change the ilayer src. I
    can tell because I've add <hr> around the <ilayer> so if the ilayer src is changed then
    the <hr> would still be there.

    Brandon Hoppe wrote:[color=blue]
    >
    > I'm trying to change the src of an ilayer in the parent document from a
    > link inside the ilayer. I'm not able to get it to work. All that happens
    > is Netscape 4 crashes. This is for Netscape 4 only.
    >
    >
    > For example, here is the main page:
    >
    > <html>
    > <head>
    > <script type="text/javascript">
    > function updateILayer(ob j) {
    > parent.document .layers["layer1"].src = obj.href;
    > }
    > </script>
    > </head>
    >
    > <body>
    > <ilayer name="layer1" id="layer1" src="home.htm">
    > </ilayer>
    > </body>
    > </html>
    >
    > And here's the home.htm src:
    >
    > <html>
    > <head>
    > </head>
    >
    > <body>
    > Click this link to go to test page:
    > <a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>
    > </body>
    > </html>
    >
    > And here's the test.htm src:
    >
    > <html>
    > <head>
    > </head>
    >
    > <body>
    > Click this link to go to home page:
    > <a onClick="parent .updateILayer(t his);" href="home.htm" >home</a>
    > </body>
    > </html>
    >
    >
    >[/color]

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: HELP: Changing ilayer src from a href link...

      Brandon Hoppe <bhoppe@ti.co m> writes:
      [color=blue]
      > Well, to keep it from crashing when you click on the link, I've change the function as such:
      >
      > function updateILayer(ob j) {
      > eval("parent.do cument.layer1.s rc=" + obj.href);
      > }[/color]

      Don't use "eval", ever. There are better ways to do what you want
      (where better is several of: shorter, faster, uses less momory, and is
      less error prone). The exceptions are so few and rare, that you are
      unlikely to hit one by accident.

      If obj.href contains "http://www.example.com ", your construction above
      will try to eval the following string:
      "parent.documen t.layer1.src=ht tp://www.example.com "
      Notice that there are no quotes around the part after the "=", so
      it is just one big syntax error.

      Try:

      parent.document .getElementById ("layer1").src= obj.href

      (layers are generally not represented by global variables, you need
      to find them the hard way).

      You could probably also do:
      parent.layers["layer1"].location.href = obj.href;
      [color=blue]
      > But it still doesn't work. It just goes to that link and doesn't
      > change the ilayer src.[/color]

      Guess: you need to return false.
      [color=blue]
      > I can tell because I've add <hr> around the
      > <ilayer> so if the ilayer src is changed then the <hr> would still be
      > there.[/color]
      [color=blue][color=green]
      >> <a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>[/color][/color]

      Yep, remember to return false:
      <a href="test.htm"
      onclick="parent .updateILayer(t his);return false">test</a>
      Returning false prevents the normal operation of the link (following
      it).

      /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

      • Brandon Hoppe

        #4
        Re: HELP: Changing ilayer src from a href link...

        Lasse Reichstein Nielsen wrote:[color=blue]
        > Don't use "eval", ever. There are better ways to do what you want
        > (where better is several of: shorter, faster, uses less momory, and is
        > less error prone). The exceptions are so few and rare, that you are
        > unlikely to hit one by accident.
        >
        > If obj.href contains "http://www.example.com ", your construction above
        > will try to eval the following string:
        > "parent.documen t.layer1.src=ht tp://www.example.com "
        > Notice that there are no quotes around the part after the "=", so
        > it is just one big syntax error.[/color]

        Yeah, I've never used eval but I was just trying anything at this point.
        [color=blue]
        > Try:
        >
        > parent.document .getElementById ("layer1").src= obj.href
        >
        > (layers are generally not represented by global variables, you need
        > to find them the hard way).[/color]

        Nope.
        [color=blue]
        > You could probably also do:
        > parent.layers["layer1"].location.href = obj.href;[/color]

        Nope.
        [color=blue]
        > Yep, remember to return false:
        > <a href="test.htm"
        > onclick="parent .updateILayer(t his);return false">test</a>
        > Returning false prevents the normal operation of the link (following
        > it).[/color]

        Oh yeah, forgot to return false. Ok, I've added return false but it still just goes to
        that link. I've tried these lines in the function call but neither worked:

        parent.document .layer1.src=obj .href;
        parent.document .getElementById ("layer1").src= obj.href;
        parent.document .layers["layer1"].src=obj.href;
        parent.layers["layer1"].location.href= obj.href;

        I've read you can change the ilayer src link but I haven't seen it done yet lol :)

        Comment

        • Brandon Hoppe

          #5
          Re: HELP: Changing ilayer src from a href link...

          Hell, I've even simplified so that the link is on the main page and I'm trying to change
          the ilayer src:

          <html>
          <head>
          <!--
          parent.document .layer1.src=obj .href;
          parent.document .getElementById ("layer1").src= obj.href;
          parent.document .layers("layer1 ").src=obj.href ;
          parent.document .layers["layer1"].src=obj.href;
          parent.layers["layer1"].location.href= obj.href;
          -->
          <script type="text/javascript">
          function updateILayer(ob j) {
          document.layer1 .src=obj.href;
          }
          </script>
          </head>

          <body>
          <a onClick="update ILayer(this);re turn false;" href="test.htm" >TEST</a>
          <a onClick="update ILayer(this);re turn false;" href="home.htm" >HOME</a>
          <hr>
          <ilayer name="layer1" id="layer1" src="home.htm">
          </ilayer>
          <hr>
          </body>
          </html>

          This doesn't work either. The ilayer area between the <hr> just goes blank when I click
          the link.


          Brandon Hoppe wrote:[color=blue]
          > Lasse Reichstein Nielsen wrote:
          >[color=green]
          >> Don't use "eval", ever. There are better ways to do what you want
          >> (where better is several of: shorter, faster, uses less momory, and is
          >> less error prone). The exceptions are so few and rare, that you are
          >> unlikely to hit one by accident.
          >>
          >> If obj.href contains "http://www.example.com ", your construction above
          >> will try to eval the following string:
          >> "parent.documen t.layer1.src=ht tp://www.example.com "
          >> Notice that there are no quotes around the part after the "=", so
          >> it is just one big syntax error.[/color]
          >
          >
          > Yeah, I've never used eval but I was just trying anything at this point.
          >[color=green]
          >> Try:
          >>
          >> parent.document .getElementById ("layer1").src= obj.href
          >>
          >> (layers are generally not represented by global variables, you need
          >> to find them the hard way).[/color]
          >
          >
          > Nope.
          >[color=green]
          >> You could probably also do:
          >> parent.layers["layer1"].location.href = obj.href;[/color]
          >
          >
          > Nope.
          >[color=green]
          >> Yep, remember to return false:
          >> <a href="test.htm" onclick="parent .updateILayer(t his);return
          >> false">test</a>
          >> Returning false prevents the normal operation of the link (following
          >> it).[/color]
          >
          >
          > Oh yeah, forgot to return false. Ok, I've added return false but it
          > still just goes to that link. I've tried these lines in the function
          > call but neither worked:
          >
          > parent.document .layer1.src=obj .href;
          > parent.document .getElementById ("layer1").src= obj.href;
          > parent.document .layers["layer1"].src=obj.href;
          > parent.layers["layer1"].location.href= obj.href;
          >
          > I've read you can change the ilayer src link but I haven't seen it done
          > yet lol :)
          >[/color]

          Comment

          • Richard Cornford

            #6
            Re: HELP: Changing ilayer src from a href link...

            "Brandon Hoppe" <bhoppe@ti.co m> wrote:[color=blue]
            > Hell, I've even simplified so that the link is on the main page
            > and I'm trying to change the ilayer src:[/color]
            <snip>

            It is a very long time since I have used an ILAYER, and I am not at home
            so I cannot check the book that I have that lists its characteristics ,
            but I seem to remember that you just cannot change their - src -
            property.

            As I recall the approach that works is to nest a LAYER inside the ILAYER
            and change its - src - instead. That required that the property accessor
            for the - src - access the outer ILAYER in the document and then the
            LAYER within the document.layers collection of the ILAYER.

            Developing exclusively for Netscape 4 is an odd thing to be doing in
            2004.

            Richard.



            Comment

            • Brandon Hoppe

              #7
              Re: HELP: Changing ilayer src from a href link...

              Richard Cornford wrote:[color=blue]
              > As I recall the approach that works is to nest a LAYER inside the ILAYER
              > and change its - src - instead. That required that the property accessor
              > for the - src - access the outer ILAYER in the document and then the
              > LAYER within the document.layers collection of the ILAYER.[/color]

              Now that works great if I change the layer src from a link in the parent document.

              But if I use a link inside the src document of the layer, then Netscape crashes. Any ideas
              why?

              Comment

              • Richard Cornford

                #8
                Re: HELP: Changing ilayer src from a href link...

                Brandon Hoppe <c1l4o2$m2g$1@h ome.itg.ti.com> wrote:[color=blue]
                > Richard Cornford wrote:[color=green]
                >> As I recall the approach that works is to nest a LAYER inside the
                >> ILAYER and change its - src - instead. That required that the
                >> property accessor for the - src - access the outer ILAYER in the
                >> document and then the LAYER within the document.layers collection
                >> of the ILAYER.[/color]
                >
                > Now that works great if I change the layer src from a link in the
                > parent document.
                >
                > But if I use a link inside the src document of the layer, then
                > Netscape crashes. Any ideas why?[/color]

                For future reference, If you ask questions on this group and don't
                provide access to the code under discussion (and preferably in an easily
                testable form) you are likely to find the process of getting help at
                least slow and often fruitless.

                Without code I can only guess at what you are doing so if my best guess
                does not correspond with what you are doing (that is, you are doing
                something other than what I guess you are doing and that is causing the
                problem) then you will have wasted my time answering at all. Which
                wouldn't encourage me to help next time (or anyone else who isn't
                willing to show their code).

                However, there certainly are problems with Netscape 4 while trying to
                swap content from within the content that is to be replaced (as I recall
                most apparent on Unix/Linux versions). I don't recall if there was a
                good solution (as I said, it has been a long time) but I would expect
                that decoupling the swapping of the content using a (global) setTimeout
                call might work.

                You would create a global function that actually swapped the - src -
                that was called with the target URL as a string parameter (and possibly
                any variable information required to resolve the reference to the ILAYR
                and LAYER elements). And then, from within the layer, call
                window.setTimeo ut with an argument that would call that function and
                provide the required URL, etc, as string literal parameters, with a
                smallish delay. That way the execution of the - src - swapping function
                should behave the same as swapping the - src - from outside of the
                LAYER.

                Richard.


                Comment

                • Brandon Hoppe

                  #9
                  Re: HELP: Changing ilayer src from a href link...

                  Richard Cornford wrote:[color=blue]
                  > For future reference, If you ask questions on this group and don't
                  > provide access to the code under discussion (and preferably in an easily
                  > testable form) you are likely to find the process of getting help at
                  > least slow and often fruitless.
                  >
                  > Without code I can only guess at what you are doing so if my best guess
                  > does not correspond with what you are doing (that is, you are doing
                  > something other than what I guess you are doing and that is causing the
                  > problem) then you will have wasted my time answering at all. Which
                  > wouldn't encourage me to help next time (or anyone else who isn't
                  > willing to show their code).[/color]

                  Of course. Sorry about that. I usually always do that. I completely agree with you. The
                  code that I have now is pasted at the bottom of this message.
                  [color=blue]
                  > However, there certainly are problems with Netscape 4 while trying to
                  > swap content from within the content that is to be replaced (as I recall
                  > most apparent on Unix/Linux versions).[/color]

                  Ahh. You've hit up on a good point there. I've been trying this with NN 4.7 on Solaris.
                  When I tried it using NN 4.7 on Windows, it worked perfectly. But I'd still like to get
                  this working on UNIX systems as well.
                  [color=blue]
                  > I don't recall if there was a
                  > good solution (as I said, it has been a long time) but I would expect
                  > that decoupling the swapping of the content using a (global) setTimeout
                  > call might work.
                  >
                  > You would create a global function that actually swapped the - src -
                  > that was called with the target URL as a string parameter (and possibly
                  > any variable information required to resolve the reference to the ILAYR
                  > and LAYER elements). And then, from within the layer, call
                  > window.setTimeo ut with an argument that would call that function and
                  > provide the required URL, etc, as string literal parameters, with a
                  > smallish delay. That way the execution of the - src - swapping function
                  > should behave the same as swapping the - src - from outside of the
                  > LAYER.
                  >
                  > Richard.[/color]

                  Ok, I've tried it using window.setTimeo ut(). But in the layer is this error when I click
                  any link, either on the main page or in home/test page:

                  Not Found

                  The requested object does not exist on this server. The link you
                  followed is either outdated, inaccurate, or the server has been
                  instructed not to let you have it. Please inform the site
                  administrator of the referring page.


                  Here's the code:

                  <!-- MAIN.HTM -->
                  <html>
                  <head>
                  <script type="text/javascript">
                  function changeLayer(obj ) {
                  document.ilayer Name.document.l ayerName.src = obj.href;
                  }
                  </script>
                  </head>

                  <body>
                  COOL<br>
                  <a href="./test.htm" onclick="window .setTimeout('ch angeLayer(this) ', 100); return
                  false;">TEST</a><br>
                  <a href="./home.htm" onclick="window .setTimeout('ch angeLayer(this) ', 100); return
                  false;">HOME</a><br>
                  <hr>
                  <ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
                  <layer name="layerName " id="layerName" src="home.htm" width=500 height=500></layer>
                  </ilayer>
                  <hr>
                  </body>
                  </html>

                  <!-- HOME.HTM -->
                  <html>
                  <head>
                  </head>
                  <body>
                  <a href="test.htm" onclick="window .setTimeout('pa rent.changeLaye r(this)', 100); return
                  false;">TEST</a><br>
                  HOME PAGE
                  </body>
                  </html>

                  <!-- TEST.HTM -->
                  <html>
                  <head></head>
                  <body>
                  <a href="home.htm" onclick="window .setTimeout('pa rent.changeLaye r(this)', 100); return
                  false;">HOME</a><br>
                  TEST PAGE
                  </body>

                  Comment

                  • Richard Cornford

                    #10
                    Re: HELP: Changing ilayer src from a href link...

                    Brandon Hoppe <c1lfoi$ep8$1@h ome.itg.ti.com> wrote:[color=blue]
                    > Richard Cornford wrote:[/color]
                    <snip>[color=blue][color=green]
                    >> You would create a global function that actually swapped the - src -
                    >> that was called with the target URL as a string parameter ...[/color][/color]
                    <snip>
                    [color=blue]
                    > function changeLayer(obj ) {
                    > document.ilayer Name.document.l ayerName.src = obj.href;
                    > }[/color]

                    I said that you should use a string parameter because you cannot
                    reliably use an object reference in the string argument for a steTimeout
                    call unless that reference is via, or to, a global property. String
                    argument setTimout code is always executed in a global context
                    (specifically, the global context to which the setTimout function that
                    is called belongs).

                    function changeLayer(url ) { //pass the url as a string
                    document.ilayer Name.document.l ayerName.src = url;
                    }

                    <snip>[color=blue]
                    > <a href="./test.htm" onclick="window .setTimeout('ch angeLayer(this) ',
                    > 100); return false;">TEST</a><br>[/color]

                    you should not need the setTimout call from code outside the layer. You
                    may as well call the - changeLayer - function directly. Changing the
                    object reference argument to a string:-

                    onclick="change Layer(this.href );return false;"

                    <snip>[color=blue]
                    > <!-- HOME.HTM -->[/color]
                    <snip>[color=blue]
                    > <a href="test.htm"
                    > onclick="window .setTimeout('pa rent.changeLaye r(this)', 100);
                    > return false;">TEST</a><br>[/color]
                    <snip>

                    When the string argument to this setTimout call is executed in the
                    global context the - this - keyword will refer to the window (global)
                    object. It does not have a - href - property, so it is the value -
                    undefined - that will be assigned to the - src - property of the LAYER.
                    Assuming that the internal setter for - src - type-converts its
                    parameter into a string, the URL assigned will be "undefined" and that
                    resource will not be found. Also, there is no point in prefixing the
                    call to - changeLayer - with "parent." as the setTimout code will
                    execute in a context where - changeLayer - is directly accessible. Try:-

                    onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                    return false;"

                    - (correcting for line wrapping) instead.

                    Richard.


                    Comment

                    • Brandon Hoppe

                      #11
                      Re: HELP: Changing ilayer src from a href link...

                      Richard Cornford wrote:[color=blue]
                      > When the string argument to this setTimout call is executed in the
                      > global context the - this - keyword will refer to the window (global)
                      > object. It does not have a - href - property, so it is the value -
                      > undefined - that will be assigned to the - src - property of the LAYER.
                      > Assuming that the internal setter for - src - type-converts its
                      > parameter into a string, the URL assigned will be "undefined" and that
                      > resource will not be found. Also, there is no point in prefixing the
                      > call to - changeLayer - with "parent." as the setTimout code will
                      > execute in a context where - changeLayer - is directly accessible. Try:-
                      >
                      > onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                      > return false;"
                      >
                      > - (correcting for line wrapping) instead.
                      >
                      > Richard.[/color]

                      Well, it works....sorta lol

                      It changes the the src of the layer, but now it just delays Netscape from crashing lol

                      Actually, Netscape crashes when I move the mouse. After I click the link, if I don't move
                      the mouse at all, Netscape will stay up until I move the mouse. Then it crashes. lol this
                      is so funny

                      Here's the changed code:

                      <html>
                      <head>
                      <script type="text/javascript">
                      function changeLayer(url ) {
                      document.ilayer Name.document.l ayerName.src = url;
                      }
                      </script>
                      </head>
                      <body>
                      <a href="test.htm" onclick="change Layer(this.href )', 100); return false;">TEST</a><br>
                      <a href="home.htm" onclick="change Layer(this.href )', 100); return false;">HOME</a><br>
                      <hr>
                      <ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
                      <layer name="layerName " id="layerName" src="home.htm" width=500 height=500></layer>
                      </ilayer>
                      <hr>
                      </body>
                      </html>

                      <html>
                      <head>
                      </head>
                      <body>
                      <a href="test.htm" onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                      return false;">TEST</a><br>
                      HOME PAGE
                      </body>
                      </html>

                      <html>
                      <head></head>
                      <body>
                      <a href="home.htm" onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                      return false;">HOME</a><br>
                      TEST PAGE
                      </body>

                      Comment

                      • Grant Wagner

                        #12
                        Re: HELP: Changing ilayer src from a href link...

                        Brandon Hoppe wrote:
                        [color=blue]
                        > Richard Cornford wrote:[color=green]
                        > > When the string argument to this setTimout call is executed in the
                        > > global context the - this - keyword will refer to the window (global)
                        > > object. It does not have a - href - property, so it is the value -
                        > > undefined - that will be assigned to the - src - property of the LAYER.
                        > > Assuming that the internal setter for - src - type-converts its
                        > > parameter into a string, the URL assigned will be "undefined" and that
                        > > resource will not be found. Also, there is no point in prefixing the
                        > > call to - changeLayer - with "parent." as the setTimout code will
                        > > execute in a context where - changeLayer - is directly accessible. Try:-
                        > >
                        > > onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                        > > return false;"
                        > >
                        > > - (correcting for line wrapping) instead.
                        > >
                        > > Richard.[/color]
                        >
                        > Well, it works....sorta lol
                        >
                        > It changes the the src of the layer, but now it just delays Netscape from crashing lol
                        >
                        > Actually, Netscape crashes when I move the mouse. After I click the link, if I don't move
                        > the mouse at all, Netscape will stay up until I move the mouse. Then it crashes. lol this
                        > is so funny
                        >
                        > Here's the changed code:
                        >
                        > <html>
                        > <head>
                        > <script type="text/javascript">
                        > function changeLayer(url ) {
                        > document.ilayer Name.document.l ayerName.src = url;
                        > }
                        > </script>
                        > </head>
                        > <body>
                        > <a href="test.htm" onclick="change Layer(this.href )', 100); return false;">TEST</a><br>
                        > <a href="home.htm" onclick="change Layer(this.href )', 100); return false;">HOME</a><br>
                        > <hr>
                        > <ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
                        > <layer name="layerName " id="layerName" src="home.htm" width=500 height=500></layer>
                        > </ilayer>
                        > <hr>
                        > </body>
                        > </html>
                        >
                        > <html>
                        > <head>
                        > </head>
                        > <body>
                        > <a href="test.htm" onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                        > return false;">TEST</a><br>
                        > HOME PAGE
                        > </body>
                        > </html>
                        >
                        > <html>
                        > <head></head>
                        > <body>
                        > <a href="home.htm" onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
                        > return false;">HOME</a><br>
                        > TEST PAGE
                        > </body>[/color]

                        The following works fine with Netscape 4.78 here:

                        <script type="text/javascript">
                        function updateILayer(ob j) { document.layer1 .src = obj.href; }
                        </script>
                        <a onClick="update ILayer(this);re turn false;" href="http://www.yahoo.com"> TEST</a>
                        <a onClick="update ILayer(this);re turn false;" href="http://www.microsoft.c om">HOME</a>
                        <hr>
                        <ilayer name="layer1" id="layer1" src="http://www.microsoft.c om">
                        </ilayer>
                        <hr>

                        If it's crashing for you, then I'd suggest you remove Netscape, copy your /User directories,
                        delete /Program Files/Netscape and reinstall Netscape 4.x

                        --
                        | Grant Wagner <gwagner@agrico reunited.com>

                        * Client-side Javascript and Netscape 4 DOM Reference available at:
                        * http://devedge.netscape.com/library/...ce/frames.html
                        * Internet Explorer DOM Reference available at:
                        * http://msdn.microsoft.com/workshop/a...ence_entry.asp
                        * Netscape 6/7 DOM Reference available at:
                        * http://www.mozilla.org/docs/dom/domref/
                        * Tips for upgrading JavaScript for Netscape 7 / Mozilla
                        * http://www.mozilla.org/docs/web-deve...upgrade_2.html


                        Comment

                        • Brandon Hoppe

                          #13
                          Re: HELP: Changing ilayer src from a href link...

                          Grant Wagner wrote:[color=blue]
                          > The following works fine with Netscape 4.78 here:
                          >
                          > <script type="text/javascript">
                          > function updateILayer(ob j) { document.layer1 .src = obj.href; }
                          > </script>
                          > <a onClick="update ILayer(this);re turn false;" href="http://www.yahoo.com"> TEST</a>
                          > <a onClick="update ILayer(this);re turn false;" href="http://www.microsoft.c om">HOME</a>
                          > <hr>
                          > <ilayer name="layer1" id="layer1" src="http://www.microsoft.c om">
                          > </ilayer>
                          > <hr>
                          >
                          > If it's crashing for you, then I'd suggest you remove Netscape, copy your /User directories,
                          > delete /Program Files/Netscape and reinstall Netscape 4.x[/color]

                          Grant, please read the previous messages. What you have here isn't the issue. Of course
                          this works. I'm trying to update the src from INSIDE the ilayer.

                          Comment

                          • Richard Cornford

                            #14
                            Re: HELP: Changing ilayer src from a href link...

                            Brandon Hoppe wrote: <c1oad1$8k8$1@h ome.itg.ti.com>
                            <snip>[color=blue]
                            > Grant, please read the previous messages. What you have here isn't
                            > the issue. Of course this works. I'm trying to update the src from
                            > INSIDE the ilayer.[/color]

                            Except that what Grant is pointing out is that, for him at least,
                            swapping the - src - on an ILAYER is possible in addition to a LAYER. I
                            finally got round to looking up the Netscape 4 layer tags in that book
                            and I was wrong about - src - swapping only working with LAYER. What I
                            was wrongly remembering was the fact that you can use document.write on
                            a LAYER but not on an ILAYER. On the other hand I can't get grants code
                            to work on Netscape 4.78 on Windows or 4.77 on Linux, and the only
                            difference is that I was testing with local (file:// protocol) files
                            instead of HTTP protocol resources (that can sometimes make a big
                            difference).

                            In any event, I managed to reproduce the crashes exactly as described on
                            Linux Netscape 4.77. I had also noticed while looking in my book that
                            Netscape 4 layers have a - load - method (two arguments, a URL and a
                            pixel width value) that I figured might be better than setting the -
                            src -, but in the context of the original code it made no difference.

                            However, I did an experiment with having two LAYERs as children of the
                            ILAYER, one hidden and z-indexed under the other. And changing the
                            source in the hidden layer and then swapping their z-indexes and
                            visibility. I made two test versions, one assigning to the - src -
                            property and the other calling the - load - method. They both worked
                            better than the original, didn't crash as soon as the mouse was moved,
                            but repeatedly swapping the document from within itself (quite quickly)
                            did crash the browser. The version that used the - load - method seemed
                            slightly more robust in this respect:-

                            <html>
                            <head>
                            <script type="text/javascript">
                            var currentLayer = 0;
                            function changeLayer(url ) {
                            var oldLayer = document.ilayer Name.document['lName'+current Layer];
                            currentLayer = (currentLayer+1 )%2;
                            var newLayer = document.ilayer Name.document['lName'+current Layer];
                            newLayer.load(u rl, 500);
                            oldLayer.visibi lity = 'hide';
                            oldLayer.zIndex = 1;
                            newLayer.zIndex = 2;
                            newLayer.visibi lity = 'show';
                            }
                            </script>
                            </head>
                            <body>
                            <a href="test.html "
                            onclick="change Layer(this.href ); return false;">TEST</a><br>
                            <a href="home.html "
                            onclick="change Layer(this.href ); return false;">HOME</a><br>
                            <hr>
                            <ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
                            <layer name="lName0" id="lName0" src="home_load. html"
                            width=500 height=500 z-index="2"></layer>
                            <layer name="lName1" id="lName1" src="home_load. html"
                            width=500 height=500 z-index="1" visibility="hid e"></layer>
                            </ilayer>
                            <hr>
                            </body>
                            </html>

                            You will have to try it out and see what you think.

                            Richard.


                            Comment

                            • Brandon Hoppe

                              #15
                              Re: HELP: Changing ilayer src from a href link...

                              Way to go Richard :)

                              This works. Netscape hasn't crashed on a Solaris machine!

                              Thanks for all the hard work.

                              Brandon

                              Richard Cornford wrote:[color=blue]
                              > However, I did an experiment with having two LAYERs as children of the
                              > ILAYER, one hidden and z-indexed under the other. And changing the
                              > source in the hidden layer and then swapping their z-indexes and
                              > visibility. I made two test versions, one assigning to the - src -
                              > property and the other calling the - load - method. They both worked
                              > better than the original, didn't crash as soon as the mouse was moved,
                              > but repeatedly swapping the document from within itself (quite quickly)
                              > did crash the browser. The version that used the - load - method seemed
                              > slightly more robust in this respect:-
                              >
                              > <html>
                              > <head>
                              > <script type="text/javascript">
                              > var currentLayer = 0;
                              > function changeLayer(url ) {
                              > var oldLayer = document.ilayer Name.document['lName'+current Layer];
                              > currentLayer = (currentLayer+1 )%2;
                              > var newLayer = document.ilayer Name.document['lName'+current Layer];
                              > newLayer.load(u rl, 500);
                              > oldLayer.visibi lity = 'hide';
                              > oldLayer.zIndex = 1;
                              > newLayer.zIndex = 2;
                              > newLayer.visibi lity = 'show';
                              > }
                              > </script>
                              > </head>
                              > <body>
                              > <a href="test.html "
                              > onclick="change Layer(this.href ); return false;">TEST</a><br>
                              > <a href="home.html "
                              > onclick="change Layer(this.href ); return false;">HOME</a><br>
                              > <hr>
                              > <ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
                              > <layer name="lName0" id="lName0" src="home_load. html"
                              > width=500 height=500 z-index="2"></layer>
                              > <layer name="lName1" id="lName1" src="home_load. html"
                              > width=500 height=500 z-index="1" visibility="hid e"></layer>
                              > </ilayer>
                              > <hr>
                              > </body>
                              > </html>
                              >
                              > You will have to try it out and see what you think.
                              >
                              > Richard.
                              >
                              >[/color]

                              Comment

                              Working...