javascript - 从 Drive 打开文件时不调用 Onfileloaded 事件

标签 javascript google-drive-api google-drive-realtime-api

我试图在我的 Google Drive 中打开一个由我的 Google Realtime 应用程序创建的文件。尽管 URL 可以正确打开,但在 afterAuth 事件之后不会触发 onfileloaded 事件。当从 Google Drive 打开由它创建的文件时,我是否应该期望并处理我的应用程序中的不同事件。在不同的窗口中复制 URL 会触发 onfileload 事件。

OnfileLoaded:

function onFileLoaded(doc) {
  Util.log.console("Doc:");
  Util.log.console(doc);
  data = doc.getModel().getRoot().get('data');
}

我还尝试处理 onLoad(模型)事件。也没有帮助。

最佳答案

/**
 * Parses the hash parameters to this page and returns them as an object.
 * @function
 */
rtclient.getParams = function() {
  var params = {};
  // The following statement was changed from window.location.hash
  // to window.location.search.  There was no hash in the URL.  So
  // .hash was returning an empty string.
  var hashFragment = window.location.search;
  if (hashFragment) {
    // split up the query string and store in an object
    var paramStrs = hashFragment.slice(1).split("&");
    for (var i = 0; i < paramStrs.length; i++) {
      var paramStr = paramStrs[i].split("=");
      params[paramStr[0]] = unescape(paramStr[1]);
    }
  }
  return params;
}

在 realtime-client-utils.js 中修复了它

关于javascript - 从 Drive 打开文件时不调用 Onfileloaded 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20395697/

相关文章:

javascript - 标题不在滚动条上移动 - Javascript

javascript - meteor &铁路由器 : TypeError: undefined is not a function

javascript - 将值从脚本文件传递给 html 中的键

android - Google Drive Api 已弃用(Google 玩游戏 -> 保存的游戏)

javascript - 仅使用 javascript 将信息提交到 Google 云端硬盘电子表格

internet-explorer - 使用 Safari 和 Internet Explorer 中的 WebViewLink 为经过身份验证的用户显示来自 Google Drive 的图像时出错

javascript - 我们可以用 ES6 Generator 做哪些不能用 for 循环做的事情?

c# - 如何使用 OAuth 在 C# 中创建新的 Google Drive 服务

node.js - 无法将文件读取流从 Google Cloud Storage 传输到 Google Drive API

php - Google drive api 将共享文件夹添加到我的文件