Tag javascript

How to get Internet Explorer javascript debugging really set up using Visual Web Developer 2008 Express (free version)

I don't know why all the existing articles out there in Internet Explorer javascript debugging always tell you to try the Microsoft Script Editor or other such steaming piles of feces from 2002. Microsoft's Visual Web Developer 2008 at least was released in the last year of the Bush presidency, instead of the beginning of the first term. They GET you by disabling the ability to attach to existing processes, but turns out you don't need to attach... you can just create an attached browser directly out of the free version.

Epic win.

First, download the free version of Visual Web Developer 2008 here. Install it. Enjoy waiting twenty minutes. Get a cup of coffee. Don't sit there waiting for the worst out of box experience ever, whatever you do.

Next, go to Internet Explorer's Internet Options and set Internet Explorer as your default browser. I know, terrible, but you gotta do it -- otherwise VWD2008 tries to use Firefox, Chrome or your other superior default browser and you lose the ability to debug IE7 in all of its awful putrescence.

While you're in Internet Options, you should also de-select disabling script debugging and enable debug messages in the Advanced tab.

Now you have to create an Empty Web Project by clicking New > New Website. Now click Debug > Start Debugging. It'll open a new IE window pointed at localhost, but just fire up whatever to-be-debugged website in that window. 

Awesome. Now any errors should drop you into the VWD2008 debugger. ROCK ON.

Javascript super killer tip: Always use innerHTML if you have no JS lib and it has to work in IE.

Recently while writing some features for Posterous, I ran into a super simple but insanely annoying bug where IE fails to properly pick up id and name fields when creating new DOM elements in JavaScript using document.createElement().

Internet Explorer completely fails to add created DOM elements to the lookup table of named elements as targets. If you generate an iframe and want to POST to it from your programmatically generated FORM tag (by setting TARGET="your_new_element_name"), you're out of luck and IE will try to create a new window instead.

InnerHTML to the rescue. The abomination of standards that is innerHTML works pretty well across all browsers. John Resig is so right when he says the DOM is a mess. Thank god for things like jquery.