我想将 aGWT
作为侧边栏嵌入到 Google 文档中。对于一个简单的jquery
网页,一切正常,但是当我嵌入最小的 GWT 应用程序时,它不会出现。我将我的 GWT 应用程序减少到最低限度:
public class TemplateBuilder implements EntryPoint {
public void onModuleLoad() {
Window.alert("hello world");
}
}
我像这样包含这个 GWT 应用程序:
在代码.gs
function showSidebar() {
var htmlOutput = HtmlService.createHtmlOutputFromFile("sidebar.html").setTitle("Template Builder").setWidth(350);
htmlOutput.setSandboxMode(HtmlService.SandboxMode.NATIVE);
DocumentApp.getUi().showSidebar(htmlOutput);
}
在 sidebar.html 中
<html>
<head>
<script src="http://remoteserver/templatebuilder.nocache.js"></script>
</head>
<body>
<div id="globalStats" />
</body>
</html>
如前所述,在 HTML 文件中包含 jquery 并使用 jquery 语句调用远程脚本在这种方法中效果很好。
现在在 Google 文档中运行 web 应用程序,javascript 和 HTML 是 CAJA-sanitized,我从我在这里读到的理解:https ://developers.google.com/apps-script/guides/html/restrictions 。然后有一个SANDBOX mode
你可以设置为 NATIVE or EMULATED
。我都试过了。
您可以使用 setSandboxMode() 方法在 Caja 的两个版本之间进行选择: NATIVE 模式比 EMULATED 模式施加的限制更少,并且通常运行得更快。相比之下,EMULATED 模式更有可能在不支持 ECMAScript 5 严格模式的旧浏览器中工作,尤其是 Internet Explorer 9。(非常旧的浏览器,包括 Internet Explorer 8 及更低版本,通常与 HTML 服务不兼容。)
无论如何,什么都没有出现,从下面的日志中,错误是:
对象 [对象对象] 没有“替换”方法
如果我可以重用我的应用程序小部件的一部分来嵌入到侧边栏,那就太好了......
有人可以阐明一下吗?
谢谢
作为参考,控制台输出:
SES initialization ses-single-frame.opt.js?debug=1:46
Problem ignored by configuration (Unsafe spec violation): Array.prototype.push does not throw on a frozen array ses-single-frame.opt.js?debug=1:43
Problem ignored by configuration (Unsafe spec violation): Extending an array can modify read-only array length ses-single-frame.opt.js?debug=1:43
Problem ignored by configuration (Unsafe spec violation): SyntaxErrors aren't always early ses-single-frame.opt.js?debug=1:43
Problem ignored by configuration (Unsafe spec violation): Array.prototype.unshift ignores sealing ses-single-frame.opt.js?debug=1:43
Problem ignored by configuration (Unsafe spec violation): Array.prototype.splice ignores sealing ses-single-frame.opt.js?debug=1:43
Problem ignored by configuration (Unsafe spec violation): Array.prototype.shift ignores sealing ses-single-frame.opt.js?debug=1:43
Repaired: Non-deletable RegExp statics are a global communication channel ses-single-frame.opt.js?debug=1:43
Repaired: Date.prototype is a global communication channel ses-single-frame.opt.js?debug=1:43
Not repaired: Eval breaks masking of named functions in non-strict code ses-single-frame.opt.js?debug=1:43
Repaired: Array.prototype.push ignores sealing ses-single-frame.opt.js?debug=1:43
Repair skipped: Array.prototype.push does not throw on a frozen array ses-single-frame.opt.js?debug=1:43
Repaired: Array.prototype.push ignores frozen ses-single-frame.opt.js?debug=1:43
Repaired: Freezing an array does not make .length immutable ses-single-frame.opt.js?debug=1:43
Not repaired: Extending an array can modify read-only array length ses-single-frame.opt.js?debug=1:43
Not repaired: [[ThrowTypeError]] has normal function properties ses-single-frame.opt.js?debug=1:43
Not repaired: SyntaxErrors aren't always early ses-single-frame.opt.js?debug=1:43
Repaired unsafely: Array.prototype.unshift ignores sealing ses-single-frame.opt.js?debug=1:43
Repaired: Array.prototype.unshift ignores freezing ses-single-frame.opt.js?debug=1:43
Repaired unsafely: Array.prototype.splice ignores sealing ses-single-frame.opt.js?debug=1:43
Repaired: Array.prototype.splice ignores freezing ses-single-frame.opt.js?debug=1:43
Repaired unsafely: Array.prototype.shift ignores sealing ses-single-frame.opt.js?debug=1:43
Repaired: Array.prototype.shift ignores freezing ses-single-frame.opt.js?debug=1:43
Repaired: Array methods as functions operate on global object ses-single-frame.opt.js?debug=1:43
Max Severity: Safe spec violation(1). ses-single-frame.opt.js?debug=1:43
440 Apparently fine ses-single-frame.opt.js?debug=1:43
10 Deleted ses-single-frame.opt.js?debug=1:43
1 Skipped ses-single-frame.opt.js?debug=1:43
Max Severity: Safe spec violation(1). ses-single-frame.opt.js?debug=1:43
initSES succeeded. ses-single-frame.opt.js?debug=1:43
沙盒模式:NATIVE 904833574-maestro_htmlapp_bin_maestro_htmlapp.js?lib=MK7wi1l9-fBV4ffZJJ9h74zcqOPkxWgv_:192
对象 [对象对象] 没有“替换”方法 904833574-maestro_htmlapp_bin_maestro_htmlapp.js?lib=MK7wi1l9-fBV4ffZJJ9h74zcqOPkxWgv_:66
Kp904833574-maestro_htmlapp_bin_maestro_htmlapp.js?lib=MK7wi1l9-fBV4ffZJJ9h74zcqOPkxWgv_:66
applyFunctionses-single-frame.opt.js?debug=1:1454
tamingNullAdviceses-single-frame.opt.js?debug=1:1338
applyFeralFunctionses-single-frame.opt.js?debug=1:1320
applyFeralFunctionses-single-frame.opt.js?debug=1:1347
tses-single-frame.opt.js?debug=1:1386
plugin_dispatchEventses-single-frame.opt.js?debug=1:1308
wrapperses-single-frame.opt.js?debug=1:1085
dispatchEventses-single-frame.opt.js?debug=1:781
(anonymous function)ses-single-frame.opt.js?debug=1:1090
_SubConfidence.amplifyses-single-frame.opt.js?debug=1:840
(anonymous function)ses-single-frame.opt.js?debug=1:1090
amplifierMethodses-single-frame.opt.js?debug=1:838
dispatchToListenersses-single-frame.opt.js?debug=1:1268
(anonymous function)ses-single-frame.opt.js?debug=1:1268
(anonymous function)ses-single-frame.opt.js?debug=1:620
execDelayedScriptsses-single-frame.opt.js?debug=1:622
signalLoadedses-single-frame.opt.js?debug=1:620
(anonymous function)ses-single-frame.opt.js?debug=1:1476
fulfilledses-single-frame.opt.js?debug=1:1419
doneses-single-frame.opt.js?debug=1:1427
fulfilledses-single-frame.opt.js?debug=1:1419
(anonymous function)ses-single-frame.opt.js?debug=1:1421
runses-single-frame.opt.js?debug=1:1420