当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Dart Window.close用法及代码示例

dart:html 库中Window.close 方法的用法介绍如下。

用法:

void close()
      override

关闭窗口。

仅当WindowBase 对象为script-closeable 并且允许调用close 的窗口浏览该窗口时,此方法才会成功。

一个窗口是script-closeable,如果它是由另一个窗口打开的窗口,或者它是一个在其历史记录中只有一个文档的窗口。

由于浏览器安全函数,一个窗口可能不允许导航并因此关闭另一个窗口。

var other = window.open('http://www.example.com', 'foo');
// Closes other window, as it is script-closeable.
other.close();
print(other.closed); // 'true'

var newLocation = window.location
    ..href = 'http://www.mysite.com';
window.location = newLocation;
// Does not close this window, as the history has changed.
window.close();
print(window.closed); // 'false'

也可以看看:

相关用法


注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 close method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。