多くの基本的な分野の知識が不足していることをお詫びしますが、Java でアプレットを作成する方法と、アプレットと Web ページ (javascript) の間の対話を可能にする方法を学んでいます。
現時点では、init() と method1() を備えたアプレットがあります。method1() は文字列を返すだけです。
アプレットは Web ページに読み込まれ、javascript で文字通り関数を参照します。
<html>
<head>
<title>Testing Applet</title>
<script>
function hello() {
result = document.wplayer.method1();
alert(result);
}
</script>
</head>
<body>
<applet code = "player.Player" name = "wplayer" archive = "player.jar" width = "600" height = "400">
</applet>
<button onClick="hello();">Interact with app</button>
method1() は文字列を返すだけです(「何とか何とか」)。
私の質問は、これが安全な方法であり、最も互換性があるかどうかです。
ありがとう!
ニック