ripper.rhetoric

Thursday, March 30, 2006

rSession 2.0

Session management for clusters that support failover with Macromedia Cold Fusion. Older code that is still applicable for sites that want more interaction and control over their session management. 2.0 is a CFC version of rSession and only requires one line of code each in Application.cfm and OnRequestEnd.cfm. Get it here.

activateActiveX

Recently, Microsoft lost a patent battle with Eolas that will affect the ActiveX functionality of Internet Explorer. Now, while I know a lot of people aren't too fond of ActiveX controls, they do have their uses and a lot of websites will be affected by this change. In about 60 days your users will start having to click any HTML elements using object, applet, or embed.

Microsoft has posted solutions and work-arounds to the problem, but as an experiment in JavaScript and the DOM, I wanted to create a script that would dynamically solve the problem on any page it's attached to.

After reading the MSDN article, I started experimenting with removing the elements from the DOM, and trying to reinsert them. In lieu of having to hand code every possible object property, I went in the direction of enumerating the objects to read the properties. That didn't work so well, as the objects have child objects that go on into infinity. My next attempt was just reusing the same object, and that failed as well...it seems Internet Explorer 7 stores info in the object itself that says it hasn't been activated yet. But, after some playing around I found the solution: remove the object via the DOM and reset the innerHTML value of the parent element.

Now, while it seems that this is just a quick fix for the lazy, it does have some real applications that couldn't be done otherwise, like fixing ColdFusion generated Flash Forms.

There are two flavors available for download:

Header version that traps the window.onload event and can be put in <head> section of your HTML document for clean, well formed code.

Footer version that won't interfere with existing window.onload events, but must be placed at the end of the HTML document.

Installation instructions are in the file. Enjoy!

Update 4/17/06:
After the final Microsoft updates, this page has been getting a lot more traffic, and some people have been emailing me about issues. It seems that this trick doesn't want to work for Shockwave elements, and people are having problems using <param> values for Flash. I will look into tweaking the script to handle this.

Update 4/4/06:
Some people have had a problem with using this script on their local machine. Internet Explorer will prompt you to let this script run if you load it locally for security reasons. However, the Internet security zone will not ask this question and will run the code without any security notifications. An example of the code in action can be found here.

Also, a comment was left that said IE7 can't tell that the objects have been loaded. This does not happen in IE6, and if anyone has an idea on how to fix this, please let me know.