🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

cors-window

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-window

CORS-Origin window/iframe comunication

0.0.0-alpha.8
latest
Version published
Weekly downloads
17
466.67%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 16 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts