1. JSONP in IE

    body

    Another post based on a previous tweet. This took me at least an hour to debug, so I thought it might be worthwhile sharing.

    IE, apparently, gets unhappy when you append nodes to the end of a node it hasn't finished rendering yet. In practice, this means it blows up when you say document.body.appendChild before the page has loaded. The easy solution? Append to a node that has already loaded! What node is almost guaranteed to be there when the body is rendering? The head node of course! Here is code:

    document.getElementsByTagName('head')[0].appendChild(script);

    Creative Commons Licence © 2006-2008 Stephen Paul Weber. Some Rights Reserved.

    Reply / Comment

    advanced comment form |

Stephen Paul Weber