首页 > 解决方案 > 在 IE11 的子窗口中打开新组件不起作用

问题描述

我按照示例https://stackblitz.com/edit/angular-rbapx4?embed=1&file=src/app/app.component.ts

产生在(点击)事件之后执行的代码:

     const componentFactory = this.resolver.resolveComponentFactory(ExampleComponent);
     let componentRef = componentFactory.create(this.injector);
     this.OpenWindow = window.open('','childwindow', 'width=400, height=400, left=150, top=200');
     this.OpenWindow.document.body.innerHTML = "";
     this.OpenWindow.document.body.appendChild(componentRef.location.nativeElement);

它在 Chrome 和 FF 中运行良好,但在 IE 中不起作用,它打开没有内容的子窗口,它只是空的,在“主控制台”中它会导致 HierarchyRequestError。我怎样才能让它在 IE 中工作?

我不能使用使用路由的解决方案,这就是我不断尝试修改上述代码的原因。我还尝试了带有 CdkPortal 的解决方案https://stackblitz.com/edit/angular-open-window,这似乎无法在 IE 中运行。

标签: javascriptangularinternet-explorer-11

解决方案


推荐阅读