Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IE11 compatibility

See original GitHub issue

Issue Description

The library is currently not compatible with IE11.

There are two issues:

  • postMessage supports only string payload
  • getOriginFromUrl seems broken, e.g. protocol and port was missing

Possible URI fix var childOrigin = new URI(window.location.href).path(url).origin(); with

A way for postMessage IE compatibility:

let Compat = {

  init: () => {
    var ieVersion = Compat.detectIE();
    Compat.stringifyPostMessages = (ieVersion !== false && Compat.detectIE() <= 11);

  detectIE: () => {
    var ua = window.navigator.userAgent;

    var msie = ua.indexOf('MSIE ');
    if (msie > 0) {
      // IE 10 or older => return version number
      return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);

    var trident = ua.indexOf('Trident/');
    if (trident > 0) {
      // IE 11 => return version number
      var rv = ua.indexOf('rv:');
      return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);

    var edge = ua.indexOf('Edge/');
    if (edge > 0) {
      // Edge (IE 12+) => return version number
      return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);

    // other browser
    return false;

  postMessage: (target, data, remoteOrigin) => {

    if (Compat.stringifyPostMessages) {
      return Compat.postMessageCompat(target, data, remoteOrigin);
    } else {
      target.postMessage(data, remoteOrigin);


  addMessageListener: (target, listener) => {
    if (Compat.stringifyPostMessages) {
      return Compat.addMessageListenerCompat(target, listener);
    } else {
      target.addEventListener(MESSAGE, listener, false);

      return {
        remove: () => {
          target.removeEventListener(MESSAGE, listener);

  postMessageCompat: (target, data, remoteOrigin) => {

    let str = JSON.stringify(data);
    target.postMessage(str, remoteOrigin);


  addMessageListenerCompat: (target, listener) => {

    let wrapped = (e) => {

      if ( &&"{")) {
        let data = JSON.parse(;
        let ec = {
          data: data,
          source: e.source,
          origin: e.origin
      } else {


    target.addEventListener(MESSAGE, wrapped);

    return {
      remove: () => {
        target.removeEventListener(MESSAGE, wrapped);




Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

Aaroniuscommented, Feb 20, 2017

Okay, I think I have this figured out and fixed in 2.4.1. You can see my changes here:

Basically, in browsers where we have to compute the childOrigin, we need to not add the port to the computed string if the port is the default for the protocol. Because we were always adding the port, it wasn’t matching the origin reported by the browser on message events.

The approach I’ve taken appears to match what’s done in the whatwg-url library here.

You might be able to view the working jsbin here:

Thanks again for reporting this issue and writing up the jsbin. Please let me know if you see any problems.

Aaroniuscommented, Feb 24, 2017

Good to hear. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix site display issues with Compatibility View in Internet ...
When a site is incompatible with Internet Explorer 11 for Windows 7, you'll see the Compatibility View button Compatibility View button in the...
Read more >
Using Compatibility View in Internet Explorer 11 - Pitt IT
Using Compatibility View in Internet Explorer 11 · 1. Click the Settings Icon on the address bar in your web browser. · 2....
Read more >
How to enable compatibility view in Internet Explorer 11 (IE11)
Click on the Settings icon in the top right corner of IE11: · Select the Compatibility View Settings item in the drop-down menu....
Read more >
Internet Explorer 11 compatibility with Network Manager GUIs
Complete the following steps to ensure compatibility with Network Manager GUIs. In your Internet Explorer 11 browser, click Tools > Compatibility View settings...
Read more >
Internet Explorer: IE8, IE9, IE10, and IE11 Compatibility mode
Internet Explorer: IE8, IE9, IE10, and IE11 Compatibility mode · Open IE · Press the ALT key to bring up the IE Menubar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found