[英]how to call a function from iframe
我在iframe中放置了一個角度應用程序,我想調用他的函數。
<iframe #iframe frameborder="0" src="http://localhost:4200/edit/username"></iframe>
http:// localhost:4200 / edit / username此鏈接是頁面編輯器的組件
export class PageEditorComponent implements OnInit...{
@Input() eventMessage = { message: ''};
handleEvent(eventMessage: { message: string; page: string }) {
// if there are any possibility to put somethings in eventMessage
if (eventMessage.message.includes('tablette')) {
this.loadIframe('tablette');
}
}
}
我的目的是從iframe調用PageEditorComponent的任何函數
查看此問題的另一種方法是使用Window.postMessage()API從iframe內部與外部進行通信。 而且您的角度代碼將不得不查找消息/事件。 它更像是用於雙方之間通信的消息總線。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.