javascript - 在 Chrome 88 更新后,top.window.close() 在 Google Editor 插件上停止工作
问题描述
我们正在使用为 google App-script Google-outhClient2提供的 Google Outh2 客户端来授权访问我们的服务器。该库在下一个选项卡中打开授权 URL,成功登录后,它将使用我们编写的自定义函数关闭选项卡
setTimeout(function() { top.window.close() }, 1);
但是,最近 Chrome 更新到 88 后,上述方法已经停止工作。这是我收到的消息
“脚本只能关闭它们打开的窗口”
当我阅读有关 Chrome 88 更改的信息时,我发现了 Google 对“Tab Hopping”的政策更改
关于如何解决这个问题的任何其他见解都会有所帮助。
在此处更新了代码工作流程
function getDriveService() {
try {
return OAuth2.createService(‘service’)
.setAuthorizationBaseUrl(authUrl)
.setTokenUrl(tokenUrl)
.setRefreshUrl(tokenUrl)
.setClientId(Client ID)
.setClientSecret(Client Secret)
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties())
.setScope('user')
.setExpirationMinutes(0)
.setParam('access_type', 'offline')
.setParam('prompt', 'consent')
}
catch(e) {
}
}
function authCallback(request) {
try {
var driveService = getDriveService();
var isAuthorized = driveService.handleCallback(request);
if (isAuthorized) {
showFile();
return HtmlService.createHtmlOutput('Success! <script>setTimeout(function() { top.window.close() }, 1);</script>');
} else {
return HtmlService.createHtmlOutput('Denied. You can close this tab');
}
}
catch(e) {
}
}
解决方案
推荐阅读
- ios - 使用笔记本电脑 react-native 在连接的 OS 设备上打开 DevMenu
- bash - 为什么 curl 不下载图片?
- angular - Angular 的 HttpClient 可以遵守 Content-Disposition 并允许保存文件吗?
- apache-kafka - 默认端口 8083 上的 Kafka Mirror Maker 2 的 REST API 调用未连接
- apache-kafka - Kafka 段被删除太频繁或根本不删除
- flutter - 有什么方法可以使用颤振的 webapp 在我自己的网站上保存数据?
- javascript - 加入购物车前如何计算产品总价?
- flutter - 如何解决 Android Studio 中的错误 24140?
- shopify - 有没有办法在 Shopify 商店中翻译块内容?
- javascript - ReferenceError = document.querySelectorAll('[data-number]')