You are here: Reference > HTML > attributes > MAYSCRIPT (applet, embed)

MAYSCRIPT attribute (applet, embed)

Browser support:
Indicates whether the Java applet is allowed to access the scripting objects of the web page.
LiveConnect is a technology that enables interaction between Java Applets and client-side scripts (such as JavaScript, VBScript). Older Java Browser Plugins (before Java version 1.6.0.10) do not allow applets to use LiveConnect by default, but that setting can be modified with the MAYSCRIPT attribute. Because of compatibility reasons (since Java Plugins in Internet Explorer always allow applets to access client-side scripts), newer Java Plugins (from Java version 1.6.0.10) do not check the MAYSCRIPT attribute, script access is always allowed in all browsers.

Possible values:

This attribute has no values.
Specifying the MAYSCRIPT attribute with an arbitrary value has the same effect as specifying it with no value.
For example, all of the following declarations have the same effect: mayscript, mayscript="true", mayscript="false", mayscript="on", mayscript="mayscript".
Although Boolean attributes may be used with no value in HTML, for XHTML compatibility, always use the MAYSCRIPT attribute in the following format: mayscript="mayscript".

Example HTML code 1:

This example illustrates the use of the MAYSCRIPT attribute:
Code
MsgBox.java
<head>
    <script type="text/javascript">
        function LiveConnectTest () {
                // call the MessageBox method of the applet
            var applet = document.getElementById ("myApplet");
            applet.MessageBox ();
        }
        function JSMessageBox () {
            alert ("JavaScript message");
        }
    </script>
</head>
<body>
    <applet id="myApplet" code="MsgBox.class" codebase="/external/examples/common/java/"
            mayscript="mayscript" style="width:300px; height:50px;">
    </applet>

    <button onclick="LiveConnectTest ()">Test LiveConnect</button>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

The applet element is deprecated. Recommendation:
Code
MsgBox.java
<head>
    <script type="text/javascript">
        function LiveConnectTest () {
                // call the MessageBox method of the applet
            var applet = document.getElementById ("myApplet");
            if (!("MessageBox" in applet)) {
                applet = document.getElementById ("myAppletFF");
            }
            applet.MessageBox ();
        }
        function JSMessageBox () {
            alert ("JavaScript message");
        }
    </script>
</head>
<body>
    <object id="myApplet" classid="clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA" width="300px" height="50px"
            codebase="http://java.sun.com/products/plugin/autodl/jinstall">
        <param name="type" value="application/x-java-applet" /> <!-- Opera, Google Chrome and Safari use the type parameter, instead of the clsid -->
        <param name="code" value="MsgBox.class" />
        <param name="codebase" value="/external/examples/common/java/" />
        <param name="mayscript" value="mayscript" />

            <!-- Firefox needs codetype, classid pair in the following form -->
        <object id="myAppletFF" codetype="application/x-java-applet" classid="java:MsgBox" width="300px" height="50px">
            <param name="codebase" value="/external/examples/common/java/" />
            <param name="mayscript" value="mayscript" />
                Your browser does not know how to execute Java applications.
        </object>
    </object>

    <button onclick="LiveConnectTest ()">Test LiveConnect</button>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content