top属性

WindowBase? top

指向窗口层次结构中最顶层窗口的引用。

如果这个<%=a href("../../dart-html/WindowBase-class.html")%><%=WindowBase%>是最顶层的<%=WindowBase%>,则<%=top%>会返回对该<%=WindowBase%>的引用。

// Add an IFrame to the current window.
IFrameElement myIFrame = new IFrameElement();
window.document.body.elements.add(myIFrame);

// Add an IFrame inside of the other IFrame.
IFrameElement innerIFrame = new IFrameElement();
myIFrame.elements.add(innerIFrame);

print(myIframe.contentWindow.top == window) // 'true'
print(innerIFrame.contentWindow.top == window) // 'true'

print(window.top == window) // 'true'

实现

WindowBase? get top;