我试图在我的 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/