我有一个使用适用于 H5 的 M3 TypeScript SDK 编写的应用程序(M3 Web 客户端)。该程序正在 Windows 上的 Chrome 中的 M3/H5 中运行。它用于处理信用卡付款,并访问 M3/H5 内 iFrame 中的处理器站点。它使用dispatchEvent 将消息传递回M3/H5。托管域和服务域是相同的。
表单、iFrame 和对话框是使用 TypeScript 动态构建的,并在生成时向它们添加适当的 CSC 标头。添加 CSC 标头框架祖先解决了我在开发过程中直接在 M3 BE 中运行时遇到的任何跨域错误问题。
但是,当我在 IOS(Infor 操作系统) 中打开 M3 时,我收到错误 “阻止了来源 [x] 的框架访问跨源框架。”,即使添加了标头。我尝试将 https:// 添加到域名、self、localhost 和所有相关域中。
出现这种情况,当然对M3/H5的回调没有完成。如果我在 IOS
outside 直接在 M3/H5 业务引擎中运行相同的代码,则不会出现错误。 DispatchEvent 起作用,M3 处理交易。
我尝试过设置各种 IOS 网格设置,但无济于事。我还向 Infor 开了一张票,但他们仍在处理中。实际的代码非常简单,但为了清楚起见,我也会提供它。我尝试过使用 postMessage 并将 targetOrigin 参数设置为“*”。
function callParentFunction(str) {
if (str && str.length > 0)
{
//Errors indicate a mismatch in domain between the page containing the iframe and this page.
console.log("callParentFunction:" + str);
var event2M3 = new CustomEvent("adn2m3", { detail: str });
event2M3.bubbles = true;
event2M3.initCustomEvent("adn2m3", true, false, { detail: str });
top.ccPaymentDiag.dispatchEvent(event2M3);
}
}
function receiveMessage(event) {
//console.log("receiveMessage");
if (event && event.data) {
console.log("call Event Origin: " + event.origin);
callParentFunction(event.data);
}
}
if (window.addEventListener) {
window.addEventListener("message", receiveMessage, false);
} else if (window.attachEvent) {
window.attachEvent("onmessage", receiveMessage);
}
if (window.location.hash && window.location.hash.length > 1) {
callParentFunction(window.location.hash.substring(1));
}
此时,我不知道如何继续。非常感谢任何建议。
谢谢;
比利
这是唯一的方法,因为这是一个安全问题。框架可以从父页面访问,因此如果您在那里输入密码,父页面可以拦截它。
我们使用O365使用类似的方式登录。