John
Norton
Developer
What better way to spend the holidays than buried in new and exciting code?! I’m talking about JavaScript here. JavaScript has come a long way in the past few years, especially with its integration with the ASP.NET framework, AJAX. But as you’re plugging away, I’d like to share with you some ways to get around my favorite Internet Explorer bug.
You’ve probably run across it once or twice and freaked (at least that’s what I did). You know that all-too-unfriendly “Operation Aborted” dialog box that leads you to the generic “Internet Explorer cannot display the webpage” landing page. How do you debug a page that won’t display? Better yet, how do you debug client side code?
Likely the first thing you’re going to do is revert your last change and spend hours walking through your last few edits and then Google the phrase “Operation aborted”. This will give you back hundreds of results and one interesting msdn post (http://blogs.msdn.com/ie/archive/2008/04/23/what-happened-to-operation-aborted.aspx). It turns out the “Operation Aborted” dialog is a lot less generic as it seems. “Operation Aborted” is thrown when an element in your DOM that has not finished rendering is modified by client side code. The most common culprit is JavaScript and because it has not finished rendering, Internet Explorer gets confused and doesn’t know where it should put the close tag for that element.
They explained it well but their steps to correct are extremely vague so I figure I’ll shed some light on my methods in correcting/preventing.
- The first thing you should do run your site through w3c’s XHTML validator (http://validator.w3.org/). Any malformed tags need to be fixed as they could be the culprit.
- If that doesn’t fix it, confirm that you don’t have any JavaScript code actively writing to unclosed elements. You want to have all your Modify and Write commands after the close tags or preferably firing off and “onload” attribute.
- If that still didn’t solve your problem or you find that the hundreds of third-party JavaScript apps your client requested don’t really want to play nice, it’s time to search for restful APIs or make good friends with iframes. I wouldn’t suggest iframes unless you’re desperate and chances are my first two solutions have already solved your problem.
If you run across another solution or way around it, or you just want to one up me, feel free to leave a comment. I’m always looking for innovative solutions.
-John