Handle the new Control Activation mechanism in IE (this howto is deprecated)Tag(s): DEPRECATED


Microsoft has now licensed the technologies from Eolas, removing the click to activate requirement in Internet Explorer. This change will be made part of the next pre-release versions of Windows Vista SP1 and Windows XP SP3. More at IEBlog

The latest IE patch introduces a new behavior with APPLETS or ActiveX controls on a page. This was done to resolve an issue concerning a patent problem with a company called Eolas.

When a web page uses the APPLET, EMBED, or OBJECT elements to load an ActiveX control, the control's user interface is blocked until the user activates it. If a page uses these elements to load multiple controls, each interactive control must be individually activated.

A tooltip "Click to activate and use this control" is shown. Then to activate an interactive control, either click it or use the TAB key to set focus on it and then press the SPACEBAR or the ENTER key. Interactive controls loaded from external script files immediately respond to user interaction and do not need to be activated.

Check out this Microsoft's white paper on the subject.

Solution #1

The workaround for an APPLET (to bypass the manual activation) is to generate in Javascript the APPLET tag but you need to generate it from an outside JS page!

<html>
  <body leftmargin=0 topmargin=0 scroll=no>
    <script src="myapplet.js"></script>
  </body>
</html>
and the myapplet.js is
document.write
  ('<applet code="MyApplet.class" height="2000" width="196"></applet>')
NOTE If you uncheck the Disable Script Debugging (Internet Explorer) option in the Advanced Tab of the Internet Options Control Panel, controls will still require activation.

NOTE: While inactive controls do not respond to direct user interaction; they do respond to script commands.

Try a page with the regular APPLET tag here.

And now the same APPLET but with an external JS file here.

Both on the same page (same Applet), here!


The workaround suggested by Microsoft is fine with static APPLET tag but if your APPLET tag needs to be generated by a JSP ou Servlet (to adjust the PARAM parameters for example) then you're out of luck because the APPLET declaration is in a JS file which is a static file.

Solution #2
As seen in this article, all you need is to change the content from an outside file. So you need a generic JS function to rewrite the APPLET tag with the original and that's it!

The main HTML (in BODY tag we call our "rewrite" function) :

<HTML><HEAD></HEAD>
<BODY onload="rewriteApplet();">
<p>This example "rewrite" the applet tag from an external JS.
This way you can generate the Applet tag from a JSP like before.
<P>
<script language="Javascript1.2" src="./rewriteapplet.js">
</script>
<APPLET CODE="TextFieldWithLimitApplet.class"
        HEIGHT=100
        WIDTH=300>
</APPLET>
</BODY></HTML>

The generic JS routine to rewrite all APPLET tags.
[rewriteapplet.js]

function rewriteApplet() {
    var v=document.getElementsByTagName("applet");
    for(i=0;i<v.length;i++){
        var el=v[i];
        el.outerHTML=el.outerHTML
    }
}
Try it here!

The same principle can be used for the OBJECT tag.

This site http://www.ediy.co.nz/internet-explorer-flash-applet-activation-fix-xidc19237.html offers a really small JS script (only 292 bytes long) to handle the situation.

IMPORTANT NOTES :

  • AFAIK, this trick does not work from a FRAME!
  • If you have PARAM tags associated with the applet then they will be replaced by two strange PARAMS (_CX and _CY)! So beware... It looks that this behaviour has something to do with the fact that the Java plugin is an ActiveX. Pre-XP SP2 installation are not supposed to do that kind of substitution (not verified!).
  • For simple applet with no param, this is an interesting generic solution.

    Solution #3
    This solution is a little bit ugly but there is no better solution when you have dynamic APPLET PARAM generated on the server-side.

    The requirement is to write only the APPLET tag from an outside JS file, the PARAMS can be handled by the main page like before! The trick is to have 2 external JS function, one to write the <APPLET> tag (and the static PARAM if any) and a second function to write the </APPLET>. The enclosed dynamic PARAM parameters are generated by the JSP (ASP page).

    [rewriteapplet.js]

    function writeHeader(urlApplet) {
     document.write
        ('<applet  codebase="' + urlApplet +  '" code="myApplet.class"')
     document.write
        ('  width="100%" height="98%" hspace="0" vspace="0" align="middle" >')
     document.write
        ('            <PARAM NAME="printdialog" VALUE="false">')
     }
    
    function writeFooter() {
     document.write('</applet>')
    }
    

    The JSP or ASP

    ...
    <script language="Javascript1.2"
       src="<%= CONTEXT_PATH %>/scripts/rewriteapplet.js">
    </script>
    ...
     <script>
      writeHeader('<%=urlApplet %>');
     </script>
     
       <%
         if(resultVB.isObjectInResult(idObject)) {
           int i = 1;
           Iterator itPages = pages.iterator();
           while (itPages.hasNext()) {
              String url = (String) itPages.next();
              %>
              <PARAM NAME="page<%=i%>" value="<%=url %>">
              <%
              i++;
            }
         }
         else {
         %>
           <PARAM NAME="page1" value="<%=fileUrlErr %>">
         <%
         }
         %>
         
    <script>
      writeFooter();
    </script> 

    blog comments powered by Disqus