0.0.0-alpha.8 • Published 1 year ago

cors-window v0.0.0-alpha.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

cors-window

Cross-origin window/iframe communication

Example

Host

const host = new DialogHost("http://localhost:7702")
host.onMessage = (data) => {
    console.log("child sent msg", data)
}
host.onChildAttach = () => {
    console.log("host has attached to existing window")
}
host.onChildOpen = () => {
    console.log("child opened a new window")
}
host.onChildClose = () => {
    console.log("child window closed")
}
setInterval(() => {
  host.post({ type: "ok", data: "data from host" })
}, 1500)

Dialog

const dialog = new DialogWindow();
dialog.onMessage = (data) => {
    console.log("parent sent message", data)
}
dialog.onParentOpen = () => {
    console.log("parent opend this window")
}
dialog.onParentAttach = () => {
    console.log("parent refreshed the window")
}
dialog.onParentClose = () => {
    console.log("parent closed the window")
}
setInterval(() => {
  dialog.post({ type: "ok", data: "data from dialog" })
}, 1500)

Examples

For full examples go to example directory

0.0.0-alpha.8

1 year ago

0.0.0-alpha.7

1 year ago

0.0.0-alpha.6

1 year ago

0.0.0-alpha.5

1 year ago

0.0.0-alpha.4

1 year ago

0.0.0-alpha.3

1 year ago

0.0.0-alpha.2

1 year ago

0.0.0-alpha.1

1 year ago