|
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?
irt.org | Knowledge Base | DHTML | Q700 [ previous next ]
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?
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;
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.