1.0.10 • Published 2 years ago

iframe-msg-promise v1.0.10

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

Simple cross domain iframe messaging with promise

NPM

Usage Example

// Frame 1
// Get the target iframe
const target = document.getElementById("iframe-target")?.contentWindow

// Send a message to the iframe
if (target) {
  postMessagePromise({
    params: {
      url: "https://jsonplaceholder.typicode.com/users/1",
      method: "GET",
    },
    win: window,
    target: target,
  }).then((resp) => {
    setData(resp)
  })
}

// Frame 2
startListening(window, doSomenthing)

Install the project & run demo

The demo emulates a cross-domain iframe where a message with variables are sent and an API response is returned to the main window.

$ yarn
$ yarn dev

License

GNU General Public License v3.0 or later

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago