Javascript Support
To enable Javascript support, MAYSCRIPT must be added to the applet tag. Javascript function calls are similar to that in standard HTML, as shown in the following example :
<applet code="navdeluxe.class" width=600 height=100 MAYSCRIPT>
<param name=menu1 value="Menu 1">
<param name=menu1url value="javascript:open('applet.html', '_blank')">
<applet>
Note that the use of Javascript is much more limited than in standard HTML. The following points are worth noting to avoid hours of debugging and frustration :
- Value and variable assignments are not supported :
<param name=menu1url value="javascript:document.body.bgcolor='#0';"> and <param name=menu2url value="javascript:open('applet.html', '_blank','toolbar=no')">
- Empty strings in arguments are not supported :
<param name=menu2url value="javascript:open('', '_blank')">
- Use single quotes (') instead of double quotes (") for arguments :
<param name=menu3url value="javascript:open('applet.html', '_blank')"> instead of <param name=menu3url value="javascript:open("applet.html", "_blank")">
- Arguments are treated as String literals during the function call. Therefore, they must be converted to the appropriate format using standard Javascript methods such as parseInt(String) and parseFloat(String).
Users can overcome most of the limitations by placing the instructions within a javascript function :
function jsfunction(color, integer){
var i = parseInt(integer)
document.body.bgcolor= color;
open('', '_blank')
open("applet.html", "_blank")
}
Known problems and bugs
If Javascript functions (namely prompt, alert and confirm) that open a dialog box are invoked, the applet will be disabled temporarily until the mouse re-enters the applet area. If possible, avoid using dialog boxes with the navigation applets.