IE ActiveX Left-click Fix By Will Fitch 01 June 2006 at 12:26 pm

For anyone who embeds Flash objects within their web pages, you know that Microsoft has added a new ?feature? for ActiveX controls. This new ?feature? requires the browser user to left-click the object before it becomes activated. If your ActiveX object is only used for displaying information, this shouldn?t be as big a deal. However, if your purpose it to interact with the end-user, they will be required to left-click in order to do so.

Working around this is relatively simple. The idea, Microsoft says, is to limit the actions of harmful ActiveX objects coded within the script that is being run. For instance, let?s say you have a Flash script called file.swf that is actually a form the user must fill out on your web page. Typically, your page would look something like this:

<html>
<head>
<title>My page</title>
</head>
<body>
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″
codebase=

“http://download.macromedia.com/pub/
shockwave/cabs/flash/swflash.cab#version=6,0,0,0″
width=”190″ height=”600″ >
<param name=movie value=”file.swf”> <param name=”quality” value=”high”> <param name=”bgcolor” value=”#ffffff”> <embed src=”form.swf” mce_src=”form.swf” quality=”high” bgcolor=”#ffffff” width=”190″ height=”600″
type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer”></embed>
</object>
</body>
</html>

Because you have placed the object directly inside of your page, Internet Explorer will now require a left-click from your users. Now, here comes the fix.

  1. Create a new file called file.js
  2. Add the object to that file and print it with document.write().
  3. Remove the object from your web page, and call the JavaScript in the same place your object was located:
    <script language=?javascript? src=?file.js?></script>

Keep in mind, you can still run dynamic code through the JS call. Just use the correct file extension and this will run the code as that.
<script language=?javascript? src=?file.aspx?></script>

If you do use a dynamic language for the JS source, ensure you send the proper headers (Content-type: text/javascript) using that language.

Your code should now look like this:
<html>
<head>
<title>My page</title>
</head>
<body>
<script language=?javascript? src=?file.js?></script>
</body>
</html>

[del.icio.us] [Digg] [dzone] [Furl] [Google] [Reddit] [Slashdot] [Sphere] [Yahoo!]

Leave a Reply