Hello.

I've done an "stupid" application to show how to modify the content of a
layer. In IE it works perfectly, but in NS4 it just works for the first
time. Instead of losing time explaining it, I attach the code (in text and
in an archive) so that you can see it. Any help will be useful !

Thanks.

The code is:
--------------------------------------------------------------------------
--------------
<HTML>
<HEAD>
<TITLE>Testing Layers</TITLE>
<script language="Javascript">
function Browser() {
        var b=navigator.appName;
        if (b=="Netscape") this.b="ns";
        else if (navigator.userAgent.indexOf("Opera")>0) this.b = "opera";
        else if (b=="Microsoft Internet Explorer") this.b="ie";
        if (!b) alert('Unidentified browser./nThis browser is not supported,');
        this.version=navigator.appVersion;
        this.v=parseInt(this.version);
        this.ns=(this.b=="ns" && this.v>=4);
        this.ns4=(this.b=="ns" && this.v==4);
        this.ns5=(this.b=="ns" && this.v==5);
        this.ie=(this.b=="ie" && this.v>=4);
        this.ie4=(this.version.indexOf('MSIE 4')>0);
        this.ie5=(this.version.indexOf('MSIE 5')>0);
        this.ie55=(this.version.indexOf('MSIE 5.5')>0);
        this.opera=(this.b=="opera");

this.dom=((document.createRange&&(document.createRange().createContextualF
ragment))?true:false);
        var ua=navigator.userAgent.toLowerCase();
        if (ua.indexOf("win")>-1) this.platform="win32";
        else if (ua.indexOf("mac")>-1) this.platform="mac";
        else this.platform="other";
}
is = new Browser();

var array_colours= new
Array("#000000","#505050","#A0A0A0","#F0F0F0","#A0A0A0","#505050","#000000
");
var txt_layer = new Array("One","Two","Three","Four");
var lay_actual=1;
var col_actual=0;

function layerWrite(id,text) {
      window.status="Changing "+id+" to "+text;
        if (is.ns4) {
                var lyr = document.layers[id].document
                lyr.open()
                lyr.write(text)
                lyr.close()
        }
        else if (is.ie) document.all[id].innerHTML = text
}


function change_colour() {
   layerWrite('ef'+lay_actual,"<span
style=\"color:"+array_colours[col_actual]+"\">"+txt_layer[lay_actual-1]+"<
/span>");
   if (col_actual==(array_colours.length-1)){
      col_actual=0;
      if (lay_actual!=4) lay_actual++;
      else lay_actual=1;
   }
   else col_actual++;
   setTimeout("change_colour()",100);
}


onload: setTimeout("change_colour()",100);

</script>
</HEAD>
<BODY color="white" bgcolor="black">
<font color='white'>Testing layers & divs. See status bar.</font>
<DIV ID="ef1" style="position:absolute; top: 50; left: 100;">One</DIV>
<DIV ID="ef2" style="position:absolute; top: 75; left: 650;">Two</DIV>
<DIV ID="ef3" style="position:absolute; top: 350; left: 50;">Three</DIV>
<DIV ID="ef4" style="position:absolute; top: 370; left: 550;">Four</DIV>
</BODY>
</HTML>

--------------------------------------------------------------------------
--------------
Title: Testing Layers
Testing layers & divs. See status bar.
One
Two
Three
Four

smime.p7s

Reply via email to