pic and text to iframe, works in IE but not Netscape

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

    pic and text to iframe, works in IE but not Netscape

    I have code that works in IE but not Netscape 7+. This code allows me
    to have a list of links that bring up an image and description in an
    iframe. This works great in IE, however I have users that are
    Netscape users.


    main page:

    var links=new Array();

    links[2]=new Array("picture2 .jpg","Pic 2 link title","Pic 2 image
    title");
    links[1]=new Array("picture1 .jpg","Pic 1 link title","Pic 1 image
    title");

    function showImg(aNum)
    {
    document.IFRAME NAME.setup(link s[aNum]);
    }

    // and so on ...

    for (var i=links.length-1;i>=0;i--)
    {
    document.write( '<a href="#" onclick=showImg ("'+i+'")>' + links[i][1] +
    '</a><br>');
    }





    the iframe file:


    <script>
    function setup(aLink)
    {
    document.getEle mentById("pic") .src=aLink[0];
    document.getEle mentById("title ").innerHTML=aL ink[2];

    }
    </script>
    <body>
    <p id="title"></p>
    <img src="" id="pic">
    </body>



  • Randy Webb

    #2
    Re: pic and text to iframe, works in IE but not Netscape

    Treetop wrote:[color=blue]
    > I have code that works in IE but not Netscape 7+. This code allows me
    > to have a list of links that bring up an image and description in an
    > iframe. This works great in IE, however I have users that are
    > Netscape users.
    >
    >[/color]

    <--snip-->
    [color=blue]
    > document.IFRAME NAME.setup(link s[aNum]);[/color]

    Stop using IE-shortcut-code and it will work in NS7+:

    document.frames['IFRAMENAME'].setup(.......) ;

    --
    Randy

    Comment

    • Treetop

      #3
      Re: pic and text to iframe, works in IE but not Netscape


      "Randy Webb" <hikksnotathome @aol.com> wrote in message
      news:8tadnZrxfK pcsJrd4p2dnA@co mcast.com...[color=blue]
      > Treetop wrote:[color=green]
      > > I have code that works in IE but not Netscape 7+. This code[/color][/color]
      allows me[color=blue][color=green]
      > > to have a list of links that bring up an image and description in[/color][/color]
      an[color=blue][color=green]
      > > iframe. This works great in IE, however I have users that are
      > > Netscape users.
      > >
      > >[/color]
      >
      > <--snip-->
      >[color=green]
      > > document.IFRAME NAME.setup(link s[aNum]);[/color]
      >
      > Stop using IE-shortcut-code and it will work in NS7+:
      >
      > document.frames['IFRAMENAME'].setup(.......) ;
      >
      > --
      > Randy
      >[/color]

      Thank you for your help.

      I changed
      document.extern al.setup(links[aNum]);

      with
      document.frames['external'].setup(links[aNum]);

      and neither browser worked. If you have time, please tell me what I
      am missing.



      Comment

      • Randy Webb

        #4
        Re: pic and text to iframe, works in IE but not Netscape

        Treetop wrote:[color=blue]
        > "Randy Webb" <hikksnotathome @aol.com> wrote in message
        > news:8tadnZrxfK pcsJrd4p2dnA@co mcast.com...
        >[color=green]
        >>Treetop wrote:
        >>[color=darkred]
        >>>I have code that works in IE but not Netscape 7+. This code[/color][/color]
        >
        > allows me
        >[color=green][color=darkred]
        >>>to have a list of links that bring up an image and description in[/color][/color]
        >
        > an
        >[color=green][color=darkred]
        >>>iframe. This works great in IE, however I have users that are
        >>>Netscape users.
        >>>
        >>>[/color]
        >>
        >><--snip-->
        >>[color=darkred]
        >>>document.IFR AMENAME.setup(l inks[aNum]);[/color]
        >>
        >>Stop using IE-shortcut-code and it will work in NS7+:
        >>
        >>document.fram es['IFRAMENAME'].setup(.......) ;
        >>
        >>--
        >>Randy
        >>[/color]
        >
        >
        > Thank you for your help.
        >
        > I changed
        > document.extern al.setup(links[aNum]);
        >
        > with
        > document.frames['external'].setup(links[aNum]);
        >
        > and neither browser worked. If you have time, please tell me what I
        > am missing.[/color]

        My bad. Change it to window.frames instead of document.frames .

        In blank.html:
        window.frames['iFrameName'].myFunction('It works');

        In blank2.html:

        function myFunction(aler tMessage){
        alert(alertMess age)
        }

        And it now works in IE6, Opera 7, NS7, Mozilla1.4

        --
        Randy

        Comment

        • Treetop

          #5
          Re: pic and text to iframe, works in IE but not Netscape

          It now works for Netscape, but not IE. I do not have enough beer in
          the house for this, lol.


          --------------------------------
          Here is the code in my test1.html file.


          <script language="javas cript" type="text/javascript">

          var links=new Array();
          links[2]=new Array("picture2 .jpg","Pic 2 link title","Pic 2 image
          title");
          links[1]=new Array("picture1 .jpg","Pic 1 link title","Pic 1 image
          title");

          function showImg(aNum)
          {
          window.frames['external'].setup(links[aNum]);
          }

          for (var i=links.length-1;i>=0;i--)
          {
          document.write( '<a href="#" onclick=showImg ("'+i+'")>' + links[i][1] +
          '</a><br>');
          }

          </script>

          <iframe name="external" id="external"
          style="width:10 0%;height:500px " src="picture.ht ml"></iframe>

          </body>
          </html>


          --------------------------------
          Here is the code for my iframe file (picture.html)

          <script language="javas cript">
          function setup(aLink)
          {
          document.getEle mentById("pic") .src=aLink[0];
          document.getEle mentById("title ").innerHTML=aL ink[2];
          }
          </script>

          <center>
          <img src="pic3.jpg" id="pic">
          <p id="title">Tex t for default picture</p>
          </center>

          --------------------------------
          My goal is to have links on a page that will update the iframe with
          the image and text from the script. The errors I get from IE 6 are:

          Error #1 - When it first loads I get
          Error: 'links[...].1' is null or not an object

          Error #2 - When I click on a link I get
          Object doesn't support this property or method

          I used the following line previous and it worked for IE but not for
          Netscape, however Error #1 was still there in IE.

          document.extern al.setup(links[aNum]);
          in place of
          window.frames['external'].setup(links[aNum]);



          Comment

          Working...