top 属性

WindowBase? top

对窗口层次中最顶层窗口的引用。

如果这个 WindowBase 是最顶层的 WindowBasetop 将返回对 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;