An exotic bug hit my desk today: A business card PDF generation system that I have programmed and maintained for several years refused to cooperate with Internet Explorer 9. It turned out there is a wired bug in the latest IE browser version.
The system creates PDF business cards from database entries and form data entered in a web page. The PDFs are then sent to a print shop to be batch printed. The code has matured over several years and works flawlessly with all versions of IE, Firefox and Chrome. So I was stunned as I got first reports of failure with IE9.
I found that the following code line that updates the iframe document threw the error:
parent.frames["bizCardFront"].location.href = "newpdf_url.pdf";
Funny enough this line worked once when it was executed for the very first time, loading the initial PDF into the iframe. But it failed on every following update of the PDF document.
As this is a productive system that is constantly used I urgently had to find a solution. I tested alternatives and was happy to finally find one that worked in IE9. Instead of using the location.href attribute of the frame document, I access the frame’s DOM node with getElementById() and alter its src attribute like this:
document.getElementById("bizCardFrontID").src = "newpdf_url.pdf";
This solution works for IE7, 8, 9 and all current versions of Firefox and Chrome.