
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
实现了父子页面之间类似 request / response 的通信方式。
iframe 子页面请求从父业面中获取用户信息
/**
* iframe 子页面。请求从父业面中获取用户信息
* @returns {Promise<void>}
*/
async function demo_sender() {
let userInfo = await corsMsg.sendCorsScript({
scriptName:'GET_USER_INFO'
});
console.log(userInfo)
}
/**
* iframe 父页面. 响应子页面的请求返回数据
* @returns {Promise<void>}
*/
corsMsg.acceptCorsScript('GET_USER_INFO', async function () {
//如果是异步结果,返回Promise对象。
return {username:'zhangsan',age:3223}
})
iframe 子页面直接在父业面中执行脚本
/**
* iframe 子页面。直接在父业面中执行脚本
* @returns {Promise<void>}
*/
async function demo2_sender() {
await corsMsg.sendCorsScript({
scriptName:'SET_USER_INFO',
scriptString:`window.currentUserInfo=${JSON.stringify({username:'李四',age:18})}` //这段代码实际上在父业面执行
});
}
/**
* iframe 父页面. 允许子页面执行SET_USER_INFO脚本
* @returns {Promise<void>}
*/
corsMsg.acceptCorsScript('SET_USER_INFO');
FAQs
实现了父子页面之间类似 request / response 的通信方式。
We found that cors-msg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.