Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q700 How can I alter the contents of a layer in Netscape Navigator 4 using *.js source files to hold the text to be used in the layers?

You are here: irt.org | FAQ | DHTML | Q700 [ previous next ]

The following does everything except use the *.js files:

<SCRIPT LANGUAGE="JavaScript"><!--
function over() {
    var text = '<FONT COLOR="red">Ha! You moved the mouse over the text<\/FONT>';
    document.layers['myLayer'].document.open();
    document.layers['myLayer'].document.write(text);
    document.layers['myLayer'].document.close();
}

function out() {
    var text = 'Move the mouse pointer over this text';
    document.layers['myLayer'].document.open();
    document.layers['myLayer'].document.write(text);
    document.layers['myLayer'].document.close();
}
//--></SCRIPT>

<LAYER ID="myLayer" onMouseOver="over()" onMouseOut="out()">
Move the mouse pointer over this text
</LAYER>

Changing it to include *.js files requires a simple test to make sure the browser supports *.js files:

<SCRIPT LANGUAGE="JavaScript"><!--
var loaded = false;
//--></SCRIPT>

<SCRIPT SRC="over.js"></SCRIPT>
<SCRIPT SRC="out.js"></SCRIPT>

<LAYER ID="myLayer" onMouseOver="if (loaded) over()" onMouseOut="if (loaded) out()">
Move the mouse pointer over this text
</LAYER>

With the contents of over.js as:

function over() {
    var text = '<FONT COLOR="red">Ha! You moved the mouse over the text<\/FONT>';
    document.layers['myLayer'].document.open();
    document.layers['myLayer'].document.write(text);
    document.layers['myLayer'].document.close();
}

loaded = true;

And the contents of out.js as:

function out() {
    var text = 'Move the mouse pointer over this text';
    document.layers['myLayer'].document.open();
    document.layers['myLayer'].document.write(text);
    document.layers['myLayer'].document.close();
}

loaded = true;

©2018 Martin Webb