Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question New layers definition in NS4 using Javascript

    Hello, I need help urgently !!!
    How to define in NS4 new layers using Javascript only, i.e. without "div" or "layer" commands
    in html body ? could you please send an answer
    to my email also : safro@wisdom.weizmann.ac.il
    or you can explain why this example is not working ?

    thank you very much

    function x()
    {
    var LR = document.layers["id"]=new Layer(100);
    LR.name= "id";
    LR.left= 100;

    LR.top = 96;
    LR.clip.height=13;
    LR.visibility='show';
    LR.zIndex=1;
    LR.bgColor=red;

    }

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    var myLayer = new Layer(200, window);

    That creates a top-level layer 200px wide.

    Then you modify it through the reference of myLayer. The second argument I believe is optional, and defaults to window if not specified. You can also provide references to other layer objects as the second argument, and the layer you are creating becomes a child of it.

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    But this example is not working.

    It is not comming to the alert !

    <html>
    <script language="Javascript1.2">
    function x()
    {
    var myLayer = new Layer(200, window);
    alert('test');
    }
    </script>
    <body>
    <script language="Javascript1.2">
    x();
    </script>
    </body>
    </html>

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    http://developer.netscape.com/docs/m...33.htm#1070570

    That says you can *only* use new Layer() AFTER the page has loaded.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •