August 23, 2008

<cfchart> in IE7

One of the greatest successes of my Intranet project was the visual representation of sales data; dynamically generated bar graphs for folks not interested in staring at a number-filled grid. However, problems arose when those sales consultants want to print the graphs. The bars, nothing more than colored <div>s, don't print well to paper or PDF. Forced as I am to use ColdFusion, I have to admit it has some perks -- including an engine to generate printable Flash graphs with a dataset.

My experiments with <cfchart> lasted about an hour before it was producing the output I wanted, but there was a hitch: Internet Explorer was vomiting, "Object expected" errors. Now, ColdFusion is an expensive and well-used tool, so I was surprised to see it malfunctioning in so obvious a fashion. As with any software, you expect there to be some snags as it interacts with a plethora of systems, but this is Internet Explorer 7, the market leader, and a core feature of the ColdFusion product.

At first I thought my issue was related to AJAX. I have a <select> control whose onChange event requests a different <cfgraph> based on the user's choice. After an hour of fiddling with my XmlHttp requests I decided to consult Google; JavaScript was not the issue. Of course, I find tons of pages describing the same problem, but only leads on a solution. I learned from Google "helpdesk" that the <noscript> tag generated by ColdFusion is the culprit.

The solution? I check my XmlHttp response for <noscript> tags and strip them out. Certainly not elegant, but it works!

No comments: