SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Let me put some pieces of code first and then I'll explain

    ------------------------------------------------------------------------

    <style type="text/css"><!--
    #l1 {position: absolute; z-index: 1; width: 40px; top: 20px; left: 20px;}
    --></style>

    *******************************************

    <body bgcolor="white" onLoad="ini_color()">

    <div id="l1">| <a href="javascript:change(1)" id="p1" class="normal"><b>1</b></a> |</div>

    *******************************************

    function ini_color() {
    if (ie4) {
    document.all.p1.style.color = "red";
    }
    if (n4) {
    document.l1.document.write("| <a href='avascript:change(1)' id='p1' class='ovr'><b>1<\/b><\/a> |")
    document.l1.document.close()
    }
    }

    *******************************************

    in external style sheet:
    a.normal:link {text-decoration: none; color: blue; font-family: arial, helvetica, sans-serif}
    a.normal:visited {text-decoration: none; color: blue; font-family: arial, helvetica, sans-serif}
    a.ovr:link {text-decoration: none; color: red; font-family: arial, helvetica, sans-serif}
    a.ovr:visited {text-decoration: none; color: red; font-family: arial, helvetica, sans-serif}
    body {color: black; font-family: arial, helvetica, sans-serif}
    div {color: black; font-family: arial, helvetica, sans-serif}

    ------------------------------------------------------------------------
    You can find the page here. The onLoad function helps to demonstrate the problem I have with NN (IE is perfect). When the DIV changes color, it slightly shifts its position (view the page with NN to see). What's causing it?

    I was suggested to use <ilayer> insrtead, but I've never used it before. Should it just be
    <ilayer id="l1">| <a href="javascript:change(1)" id="p1" class="normal"><b>1</b></a> |</ilayer>
    or should it be
    <ilayer><layer id="l1">....</layer></ilayer>

    And what is a proper way to reffer to that <ilayer> in NN? May be I was looking in all the wrong places, but i couldn't find any info on that.

    I need to change that number's color, but not onmOuseOver/onMouseOut, but using my own function whenever needed (I do not need to create any hover effects).

    Any help would be greatly appreciated.

  2. #2
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok,
    let me cut it all, so that it will be much shorter:
    if I have the following structure:
    <div><ilayer><layer>...</layer></ilayer></div>

    what is the proper hierarchy to refer to the layer in NN in this situation?
    DIV will be used by IE, ILAYER and LAYER by NN.
    the thing I'm trying to do has to alternate the layer's content using my own function and has nothing to do with MouseOver/Out - that's why I need to know the proper way to access my layer (in NN) so that I will be able to overwrite its content.

    Any help would be greatly appreciated.
    Valeria

  3. #3
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I didn't read much through your first message...too convoluted for me

    But, I did read your second one, and I think this is what you want to know. First, use:

    <ilayer id="ilayer1"><layer id="layer1"><div id="div1">...</div></layer></ilayer>

    Note that if you are rewriting content, specify the width and height of ilayer to it's "biggest" position (if the "stuff" you have in there already doesn't make it its biggest position).

    then:

    Code:
    if(document.getElementById){
    document.getElementById("div1").innerHTML = "new HTML code";
    }else if(document.all){
    document.all["div1"].innerHTML = "new HTML code";
    }else if(document.layers){
    with(document.layers['ilayer1'].document.layers['layer1'].document){
    open();
    write('new HTML code');
    close();
    }}
    Hope that's what you wanted

    aDog

  4. #4
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aDog,
    thanks for replying. You are probably wondering why such a compliaced solution?

    The reason I started looking for one is because the one that seemed most obvious to me didn't work. Even if I create a separate page for NN and have the following:
    <layer id="l1">| <a href="javascript:change(1)" class="norm"><b>1</b></a> |</layer> (I position the layer in the sylesheet in the head of the page)

    and in my javascript code I have this:
    var text
    text = "| <a href='javascript:change(1)' class='ovr'><b>A<\/b><\/a> |"
    document.l1.document.open()
    document.l1.document.write(text)
    document.l1.document.close()

    It just doesn't work!!! the JavaScript console is blank - no error messages, but nothing is overwritten. Any suggestions?
    I've stared at this piece of code for so long i'm sick of it, but...

    Thanks for your help,
    Valeria


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
  •