What browsers support the window.postMessage call now?

前端 未结 5 1062
温柔的废话
温柔的废话 2020-12-01 10:27

What are all the browsers that support the window.postMessage call now? I am looking for browsers that support it natively, not through an iFrame hack.

5条回答
  •  自闭症患者
    2020-12-01 10:57

    postMessage is supported in IE8+ HOWEVER

    • Remember that IE9 and below require data to be passed in string form and not as an object.
    • IE doesn't like you to call postMessage as soon as page loads (I'm assuming this has to do with the iframe you are posting to needing time to load).
      Use a setTimeout to wait one or two seconds before calling postMessage.
      It took me hours to figure this out and IE wasn't giving me any error message, it was just silently doing nothing until I added the setTimeout.

    If you want to start with a demo which actually does work in IE, check out this nifty tutorial by Ilya Kantor

提交回复
热议问题