我的图像(托管在 Google Cloud Storage 中)的元数据具有名为 的属性downloaded,如果图像已下载,则downloaded键中的值将从 更改0为1。
https://cloud.google.com/storage/docs/viewing-editing-metadata#storage-view-object-metadata-nodejs中的代码显示了如何查看元数据,但并未真正涵盖如何更改元数据。
有可能这样做吗?
javascript node.js google-cloud-storage google-cloud-platform
我正在尝试激活页面重新加载器预防器,并能够停用重新加载器预防器。换句话说,当用户即将卸载/重新加载其页面时,我能够显示一个对话框,但我目前正在寻找一种方法,让用户在某个功能之后卸载/重新加载其页面,而无需任何对话框或警告已被调用。
也许删除事件侦听器会有帮助?
这是我正在使用的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button onclick="activateReloader()">activate</button>
<button onclick="deactivateReloader()">deactivate</button>
<script>
function activateReloader() {
window.addEventListener('beforeunload', function (e) {
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = '';
});
}
function deactivateReloader() {
window.removeEventListener('beforeunload', function (e) {});
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)