【发布时间】:2019-02-12 02:04:04
【问题描述】:
我的任务是在 iframe 中找到活动元素。
这是在当前文档不是 iframe 时有效的代码
public componentWillMount(): void {
this._originalFocusedElement = getDocument()!.activeElement as HTMLElement; }
对于 iframe,我确实遇到了this 堆栈溢出帖子,并尝试在我的代码中使用它,如下所示
public componentWillMount(): void {
this._originalFocusedElement = getDocument()!.contentWindow.document.activeElement;
}
但是,这不会编译。
任何关于如何在 iframe 中找到活动元素的指导都会很有用。
【问题讨论】:
标签: reactjs typescript iframe