After the applet is complete, you need to start writing JavaScript. Because Javascript is also interpreted by the browser, it can easily interact with the applet.
// @ Author zenny Chen
// First loaded JavaScript function for communication with the specified Applet
Function accessapplet ()
...{
If(window.doc ument. testapplet! = NULL )...{
VaR IP = Window. Location. href;
Window.doc ument. testapplet. setsocketurl (IP );
Optional values Doc ument. testapplet. setmayrun (true );
SetTimeout ("loopprocessapplet ()", 1000 );
}
}
Function loopprocessapplet ()
...{
Processapplet ();
SetTimeout ("loopprocessapplet ()", 1000 );
}
Function processapplet ()
...{
If(registry.doc ument. testapplet = NULL)
Return;
VaR STR = Invalid Response Doc ument. testapplet. geturlname ();
If (STR! = "")...{
Zookeeper Doc ument. testapplet. clearurlname ();
VaR win = Window. Open (STR, "", "Height = 300, Top = 100, Left = 100, toolbar = No, menubar = No, status = No ");
Win. Close ();
}
}
// First loaded JavaScript function for communication with the two specified applets
Function accessappletdual ()
...{
VaR IP = Window. Location. href;
If(window.doc ument. testapplet! = NULL )...{
Window.doc ument. testapplet. setsocketurl (IP );
Optional values Doc ument. testapplet. setmayrun (true );
}
If(registry.doc ument. testapplet2! = NULL )...{
Window.doc ument. testapplet2.setsocketurl (IP );
If(registry.doc ument. testapplet = NULL)
Optional values Doc ument. testapplet2.setmayrun (true );
}
If(window.doc ument. testapplet = NULL & window.doc ument. testapplet2 = NULL)
Return;
SetTimeout ("loopprocessappletdual ()", 1000 );
}
Function loopprocessappletdual ()
...{
Processappletdual ();
SetTimeout ("loopprocessappletdual ()", 1000 );
}
Function processappletdual ()
...{
If(window.doc ument. testapplet! = NULL )...{
VaR STR = Invalid Response Doc ument. testapplet. geturlname ();
If (STR! = "")...{
Zookeeper Doc ument. testapplet. clearurlname ();
VaR win = Window. Open (STR, "", "Height = 300, Top = 100, Left = 100, toolbar = No, menubar = No, status = No ");
Win. Close ();
}
}
If(registry.doc ument. testapplet2! = NULL )...{
If (! Invalid parameter Doc ument. testapplet2.getisover ())...{
If(registry.doc ument. testapplet = NULL)
Optional values Doc ument. testapplet2.setmayrun (true );
Else
Registry.document.testapplet2.setmayrun(registry.doc ument. testapplet. getisover ());
}
VaR STR = Invalid Response Doc ument. testapplet2.geturlname ();
If (STR! = "")...{
Zookeeper Doc ument. testapplet2.clearurlname ();
VaR win = Window. Open (STR, "", "Height = 300, Top = 100, Left = 100, toolbar = No, menubar = No, status = No ");
Win. Close ();
}
}
}
The preceding Code consists of two parts: accessapplet (), loopprocessapplet (), and processapplet (), which are used to control an applet in a web. What follows dual is that a page contains two such applets which need to be controlled by JavaScript.