SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    access to layers stylesheet

    Hello

    can someone tell me quickly what the path to a layers z-index is on both ie and ns? i thought this was it for ie but can't seem to get it to work??

    document.all('layername').style.z-index = 1;


    thanks in advance
    gar

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all is a collection not supported by NN as far as i'm aware.

    Try this:

    Code:
    function de(o){
         return document.getElementById(o);
         }
    That way - you can reference things easily by using de(id) and you can add logic to the function if you want to make
    it more compatible for other browsers.



    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw - for real JS hardcorers that might be wondering why de is a function and not an assignment - NN6 doesn't like function replacement by assignment.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    not sure how to get your code working as i have'nt used return in javascript before.

    set up the function you suggested as follows.....
    function id(myelement)
    {
    return document.getElementById(myelement);
    }

    which is called like so....
    mylayer = id('mylayer');

    this seems to work because if i test it in an alert i get [object DIV] however as soon as i go to use it like so...
    mylayer.visibility = "hide";

    no luck??? will this work for nn (4+) and ie(5+)?

    thanks in advance
    gar

  5. #5
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Try this

    Hello!

    You have to use <div style="position:absolute">text</div>
    if NS4 shall see it as a layer.

    Then you access it.

    function getCSS(id) {
    if(document.GetElementById)// NS6 & IE5
    return document.GetElementById(id).style;
    else if(document.all)// IE4
    return.document[id].style;
    else if(document.layers)// NS4
    return document.layers[id];
    }

    Now you can set Z-index.
    yourVar.Z-index = 1;

    For NS4 visibility "show | hide"
    For IE visibility "visible | hidden"

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason why you're having trouble is that id is obviously
    a reserved key word in the dom.
    That's why my function was called de - because it's impartial.

    you have to continue to use the reference to access visibility:

    de('mylayer').style.visibility='hidden';

    Personally - i'd tell you not to bother trying to support NN4 - it's not compliant to standards - so why should we
    try to incorporate it's backward ways and unfortuante users.

    But that's just me.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #7
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello

    thanks forgot 'id' was a reserved word in javascript, think i will forget about coding it to work in nn4 as there are many other problems concerning <divs>, the most notable being when you resize the page most of the css is lost.

    anyway that works now thanks
    a+
    gar


Bookmarks

Posting Permissions

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