0
我有一个创建iframe的角度服务。现在,在这个iframe的onLoad上,我想调用一些相同服务的功能。如何以编程方式创建的iframe的onLoad调用this.somefunction()?
private createIframe() {
let iframe = document.createElement('iframe');
iframe.onload = function() { this.somefunction();}
iframe.style.display = 'none';
this.aAuthService.createLoginUrl('').then(function (url) {
iframe.src = url;
});
document.body.appendChild(iframe);
}
private somefunction() {...}
我收到错误说 “somefunction上不存在HTMLIframeElement”。
如何在动态创建iframe时从onload调用somefunction()?