Author Topic: A javascript listening problem  (Read 2267 times)

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
A javascript listening problem
« on: May 20, 2004, 12:08:11 pm »
Hi, I hope this is my last problem….. After I’ve got the obj ID, I need to pass this value to a javascript that displays this value in the other side of my web page. So I’ve written the following code:
Code: [Select]


<html>
<head>
<title>ThreeDSim</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" topmargin=0 rightmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<table>
<tr>
<td>&</td></tr>
<tr>
<td valign="middle" align="left">
<font size="5" face="arial">Road Accident Area</font><br>
<applet name="ThreeDSim"  code="ThreeDSimApplet" width="640" height="480"></applet>
<br>
</td></tr>
<tr>
<td>
 <script type="text/javascript">
    <!--
    var temp = document.applets[0].feritoID;
    document.writeln(temp);
   // -->
  </script>
</td>
</tr>
</table>
</body>
</html>


and it works…. The problem is that the javascript obviously reads the feritoID value just when it’s loaded instead I need that the javascript reads this value whenever I make a click on the applet and so, this value changes. Exist a way to perform this task?

Bye and thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
A javascript listening problem
« Reply #1 on: May 20, 2004, 12:46:56 pm »
I don't think so. At least i don't know of a way to make Javascript on a web page run when triggered from inside the applet. I suggest to use polling instead. Do something like

Code: [Select]

window.setInterval("pollApplet()",250);
.
.
.
funtion pollApplet() {
    var temp = document.applets[0].feritoID;
    // Do stuff with "temp" here  
}


This will set temp to feritoID every 250ms.

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
A javascript listening problem
« Reply #2 on: May 21, 2004, 02:30:09 pm »
Ok, it works, thanks a lot  :D