George Hester wrote:
I have an applet which is a cube each face if which is a link. I
have a floating <DIV> element which when the mouse is over the applet
it pops up showing the text of all the links in the applet. What I
would like is when the mouse is over one of the faces of the cube the
corresponding text in my <DIV> will highlight.
So in other words this is sort of like have a link on a page and when
the mouse is held over it, some other area of the html page will
highlight. If the link itself highligts that is no problem. I would
just like some other area of the page to highlight.
If you really have a Java applet and want it to change the style of an
element in the HTML page containing the Java applet then you need to
allow the applet to script with
<applet mayscript
in the HTML code and inside your applet code you need to
import netscape.javascript.*;
and you can then instantiate the JavaScript window object from Java as
follows
JSObject window = JSObject.getWindow(this);
The window object has then methods outlined at
http://devedge.netscape.com/library/...e/lcjsobj.html
for instance a call method so that you could call a function in the page
window.call("highlightLinkText", new Object[] {"textId"});
Then in the HTML page write a JavaScript function
function highlightLinkText (elementId) {
var element;
if (document.getElementById) {
element = document.getElementById(elementId);
if (element && element.style) {
element.style.backgroundColor = 'lightblue';
}
}
}
and set up the text for each link to have an id e.g.
<p id="link1Text">...</p>
The whole process of Java->JavaScript communication is called
LiveConnect and is not supported by all browsers on all platforms as it
depends on the Java VM supporting it.
--
Martin Honnen
http://JavaScript.FAQTs.com/