Internet Explorer, printing error in preview.dlg on a web page

TL;DR

  • IE 7 it's a disgrace
  • Rename an ID to solve your printing issues

The day before holiday closing, a customer who recently we developed a website calls me and say “Did you see our website? It says it’s impossible to print due to an error on script xyz”.

 IE error while printing At the first moment, I got down from the clouds, also because AFAIK the print function is independent of the website showed. Besides, the customer wasn’t using a custom print button, but that one in the IE toolbar.

As it was the day before holidays, both customer and I decided to postpone the debug till the office reopened.

What was the issue?

After some tests (IE, Firefox, Safari, Opera), I wasn’t able to reproduce the error, so I thought the problem was somehow an external cause. The affected computer was an XP SP2, connected with a slow network that resulted in IE 7 not updated with the latest patches.

So I created a virtual machine replicating the same environment and … ta-daaaaa: the error was there at line 1401, then line 1200 … and so on. Of course, there were not lines of the HTML code which was counting just 100 rows.

Again, everything was suggesting the error being elsewhere but not in the HTML code, also because the both of them were validated. However, the error was continually appearing on every page, and it was systematically showing up every time the print button was pressed.

After some google research returned anything useful (the only thing was about an unrealistic DLL registration), I decided to proceed in the old manner. I disassembled the HTML code into small parts, testing them individually until I deleted a tags’ named div. That’s the issue: by renaming the tag, everything went back to work.

Once again a prove that IE is a disgrace and it should be trashed.