{"id":20226247,"url":"https://github.com/steamerjs/steamer-cross","last_synced_at":"2025-04-10T17:06:29.870Z","repository":{"id":21870903,"uuid":"25194472","full_name":"steamerjs/steamer-cross","owner":"steamerjs","description":"cross domain communication util","archived":false,"fork":false,"pushed_at":"2016-08-09T04:58:40.000Z","size":76,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"v2.0.0","last_synced_at":"2025-03-24T14:46:30.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steamerjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-14T07:12:51.000Z","updated_at":"2020-09-13T09:53:11.000Z","dependencies_parsed_at":"2022-08-20T01:30:32.981Z","dependency_job_id":null,"html_url":"https://github.com/steamerjs/steamer-cross","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steamerjs%2Fsteamer-cross","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steamerjs%2Fsteamer-cross/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steamerjs%2Fsteamer-cross/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steamerjs%2Fsteamer-cross/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steamerjs","download_url":"https://codeload.github.com/steamerjs/steamer-cross/tar.gz/refs/heads/v2.0.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248260492,"owners_count":21074210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:16:54.741Z","updated_at":"2025-04-10T17:06:29.846Z","avatar_url":"https://github.com/steamerjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## steamer-cross\ncross domain communication for development\n\n\n## Features\n* Bi-drectional communication\n\t- parent can send/broadcast message to children\n\t- chidren can send/broadcast message to parent and other children\n* Chaining method\n\t- ie, cross.register().send()\n* Iframe And New Window Supported\n\t- IE8 - IE9 may have problems in new window communication\n* Exclude Support For IE6 and IE7\n\n\n## Usage\n### Parent Send Message to Children\n\n#### Send message to specific child\n```\nvar cross = new Cross('project1', 'parent');\ncross.register('iframe1', document.getElementById('iframe1').contentWindow);\n\ncross.send('iframe1', \"hello ifram1, from parent\");\n```\n\n#### Broadcast message to all children\n```\nvar cross = new Cross('project1', 'parent');\n\n// chaining methods\nvar window1 = window.open('./window1.html');\ncross.register('iframe1', document.getElementById('iframe1').contentWindow)\n\t .register('iframe2', document.getElementById('iframe2').contentWindow)\n\t .register('window1', window1);\n\ncross.broadcast(\"broadcast message, from parent\");\n```\n\n#### Listen to message\n```\nvar cross = new Cross('project1', 'iframe1');\n\ncross.listen(function(msg, event) {\n\t// do something here\n});\n```\n\n#### Clear registration\n```\n// unregister specific child\nvar cross = new Cross('project', 'parent');\ncross.register('iframe1', document.getElementById('iframe1').contentWindow);\ncross.unregister('iframe1');\n\n// unregister all children\ncross.unregister();\n```\n\n### Child Send Message to Parent or Other Children\n#### Send message to parent\n```\nvar cross = new Cross('project', 'iframe1');\n// if current window is iframe, use window.parent as parent reference\ncross.register('parent', window.parent)\n      send('parent', 'hello parent, from iframe1');\n```\n\n#### Send message to specific child\n```\nvar cross = new Cross('project', 'window1');\n// if current window is a new window, use window.opener as parent reference\ncross.register('parent', window.opener)\n\t .send('iframe2', 'hello ifram2, from iframe1');\n```\n\nThe child which receives message from another child may not know which child send this message to it.\nthe `event` parameter in `cross.listen` function only contains parent's information. Therefore, if you hope to identify the actual source, you may include the sourcing information in your message like following:\n```\nvar cross = new Cross('project', 'window1');\ncross.register('parent', window.opener)\n\t .send('iframe2', JSON.stringify({content: 'hello ifram2, source: 'iframe1'}), from iframe1');\n```\n\n#### Broadcast message to parent and all children\n```\nvar cross = new Cross('project', 'iframe1');\ncross.register('parent', window.parent)\n\t .broadcast('broadcast from iframe1, project1');\n```\n\n## Demo\nPlease checkout the repo, and take a look at `test` folder","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteamerjs%2Fsteamer-cross","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteamerjs%2Fsteamer-cross","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteamerjs%2Fsteamer-cross/lists"}