Angular 角度4设置值,形成iframe的输入字段
我在angular 4应用程序中与其他域一起使用iframe,希望在iframe表单输入字段中指定值 我们有没有办法做到这一点Angular 角度4设置值,形成iframe的输入字段,angular,iframe,Angular,Iframe,我在angular 4应用程序中与其他域一起使用iframe,希望在iframe表单输入字段中指定值 我们有没有办法做到这一点 谢谢。我以前也遇到过类似的问题:我认为在这种情况下,您需要做两件事: ulitize两个应用程序(嵌入应用程序和iframe应用程序)之间的消息传递层 扩展两个应用程序的代码(以便iframe可以处理您通过浏览器发送给它的消息) 如果应用程序位于不同的域上,则由于 要做到这一点,你必须充分利用 基本思想: 嵌入应用程序启动,iframe应用程序启动 iframe应用
谢谢。我以前也遇到过类似的问题:我认为在这种情况下,您需要做两件事:
- ulitize两个应用程序(嵌入应用程序和iframe应用程序)之间的消息传递层
- 扩展两个应用程序的代码(以便iframe可以处理您通过浏览器发送给它的消息)
窗口订阅消息。addEventListener(“消息”,receiveMessage,false)代码>
@ViewChild('iframeRef')iframeRef:ElementRef代码>
this.iframeRef.nativeElement.contentWindow.postMessage({iframe的某个消息对象},'*',[])代码>
iframe应用程序处理消息
function receiveMessage(event){
console.log("Received a message From: Angular", event);
// if (event.origin !== "http://example.org:8080")
// return;
// todo: this is crucial for being secure!
....
}
我以前也遇到过类似的问题:我认为在这种情况下,您需要做两件事:
- ulitize两个应用程序(嵌入应用程序和iframe应用程序)之间的消息传递层
- 扩展两个应用程序的代码(以便iframe可以处理您通过浏览器发送给它的消息)
窗口订阅消息。addEventListener(“消息”,receiveMessage,false)代码>
@ViewChild('iframeRef')iframeRef:ElementRef代码>
this.iframeRef.nativeElement.contentWindow.postMessage({iframe的某个消息对象},'*',[])代码>
iframe应用程序处理消息
function receiveMessage(event){
console.log("Received a message From: Angular", event);
// if (event.origin !== "http://example.org:8080")
// return;
// todo: this is crucial for being secure!
....
}