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

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    i got problem in understanding layer in javascript .....

    my question :
    1. how can i make a layer into an object in java script
    2. below is the script i make but it contains error " greenb is not an object "
    i dont know why ...

    can any boy help me ....


    <body >
    <layer name="greenb" width="15" height="15" left="5" top="1">
    <img src="green.gif">
    </layer>

    <script type="text/javascript" language = "javascript">
    <!--
    var greenb = document.all["greenb"];
    greenb.left = 10;
    //-->
    </script>
    </body>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    27
    Rep Power
    0
    You're using a strange mix of Netscape only HTML tags (<layer> ) and IE only javascript (document.all)!! You need to use this code to access the layer's properties in IE. It uses in-line stylesheets to set the left/top/height/width properties -

    <body >
    <div id="greenb" style="width:15;height:15;left:5;top:1">
    <img src="green.gif">
    </div>

    <script type="text/javascript" language = "javascript">
    <!--
    var greenb = document.all["greenb"];

    // CHANGED HERE....

    greenb.style.left = 10;
    //-->
    </script>
    </body>

    NOTE - this will only work with IE4+. It will not work with NN4 or NN6 as the methods for accessing layers are completely different. For information on that visit www.Netscape.com . For more info on dhtml and stylesheets in general, visit http://hotwired.lycos.com/webmonkey/index.html


    [This message has been edited by mmonks (edited December 05, 2000).]

    [This message has been edited by mmonks (edited December 05, 2000).]

Similar Threads

  1. .NET Server Controls + Javascript + Layers
    By tansage in forum JavaScript Development
    Replies: 0
    Last Post: October 13th, 2003, 03:33 PM
  2. javascript layers
    By deeyeskay in forum JavaScript Development
    Replies: 2
    Last Post: October 10th, 2003, 04:46 AM
  3. Replies: 6
    Last Post: October 1st, 2003, 05:15 PM
  4. Javascript rollovers and layers
    By gunja99 in forum JavaScript Development
    Replies: 1
    Last Post: November 11th, 2002, 05:45 AM
  5. Layers in javasCript...
    By Adrianf in forum JavaScript Development
    Replies: 0
    Last Post: February 2nd, 2000, 07:56 AM

IMN logo majestic logo threadwatch logo seochat tools logo