Refactor postMessage use, defend against failure in IE