#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    San Luis Obispo, CA, USA
    Posts
    1
    Rep Power
    0
    Hi:

    I'm up aginst a newZilla problem and struggling to get Netscape 6 methodology. Basically I need to change and image in a DIV element "layer" in IE, NS4, AND NS6.Here's a fragment that works for NS4 and IE 4,5, but fails in NS6 on the thisLayer.document call in the change_Image function with an "thisLayer.document has no properties" error msg. I've tried fooling with the thisLayer syntax and some of the new Child methods, but with no luck. I suppose I just don't get the syntax or method idea. Anyone got a clue?

    thisLayer = "undefined";
    var newImage = new Image();
    newImage = "newImage.jpg";

    function change_image() {
    //here's where the NS6 code fails...
    thisLayer.document.images.myImage.src=newImage.src;
    }


    <div id="image1">
    <script language=javascript>
    <!--
    document.write("<img src="oldImage.jpg" name="myImage" width="320" height="240" vspace="0">");

    if (ns4)
    lf1 = parent.document.layers["image1"];
    if (ie4) {
    lf1 = parent.document.all["image1"];
    lf1.style.zIndex=1;
    }
    if (ns6){
    lf1 = parent.document.getElementById("image1");
    lf1.style.zIndex=1;
    }
    thisLayer = lf1;
    //-->
    </script>
    </div>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    I had this exact problem yesterday, NOw I am no expert in DHTML but I came up with this code which works beautifully in all three browsers (ie4+, ns4, ns6)

    function changeImage(layer,imgName,imgObj) {
    if (document.images) {
    if (n && layer!=null) {
    eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
    }
    else {
    document.images[imgName].src = eval(imgObj+".src")
    }
    }
    }

    Sample usage

    <div id="nav1">
    <a href="#" onMouseOver="changeImage('nav1','sub1','sub1_on'); " onMouseOut="changeImage('nav1','sub1','sub1_off');"><img src="images/sub1_off.gif" width="60" height="20" name="sub1" border="0" alt="Sub1" hspace="0" vspace="0"></a></div>

    [This message has been edited by freddydoesphp (edited December 07, 2000).]

Similar Threads

  1. Netscape 7 & Dynamic DIV bug
    By FragMaster B in forum HTML Programming
    Replies: 1
    Last Post: October 29th, 2003, 05:48 PM
  2. Specific Netscape 7, show/hide div problem
    By khwang in forum HTML Programming
    Replies: 5
    Last Post: October 17th, 2003, 10:39 PM
  3. Netscape 6 DHTML: Height of unspecified DIV... HELP!!!!!
    By Miggity in forum JavaScript Development
    Replies: 5
    Last Post: October 10th, 2003, 02:16 AM
  4. DIV in Netscape
    By 3e3c3e in forum HTML Programming
    Replies: 3
    Last Post: October 22nd, 2001, 01:23 PM
  5. Javascript with div tag in Netscape
    By bramsey in forum JavaScript Development
    Replies: 2
    Last Post: October 16th, 2001, 09:24 AM

IMN logo majestic logo threadwatch logo seochat tools logo