在此代码中的什么位置可以为应用程序添加自定义尺寸?
Where in this code would I add custom sizes for the application?
我在 Google 脚本编辑器中创建了一个脚本,这样当用户单击 Google 表格中工具栏上的菜单时,它会弹出一个应用程序框,用户可以在其中单击以进行打印。
但是,我不确定如何为出现的那个应用程序框添加自定义尺寸而不会弄乱代码。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below to print using the Google Cloud Print service.');
}
和index.html代码是:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script src="https://www.google.com/cloudprint/client/cpgadget.js">
</script>
<script>
window.onload = function() {
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(
cloudprint.Gadget.createDefaultPrintButton("button"));
var liabilityWaiver = waiver.getAs(MimeType.PDF);
gadget.setPrintDocument("url", "Test Page", "https://drive.google.com/open?id=0B3NraNAa2RhWSldiNklPVGI5OU0");
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
以下是脚本功能的图片说明:
从最后一张图可以看出,问题出在这里,应用程序框太小,无法容纳所有信息,因此将其删除。
-编辑-
在一位用户 Matt 的帮助下,我设法弄清楚了如何创建更大的应用程序框。然而,即使盒子变大,Google 云打印服务所在的 window 大小仍然很小,无论我将外部应用程序盒子做多大。 (参考下图。)
谁能帮忙把内箱做成外箱的全尺寸?或者只是简单地把它变大?
此致。
查看https://developers.google.com/apps-script/reference/base/ui#showmodaldialoguserinterface-title
var htmlOutput = HtmlService
.createHtmlOutput('<p>A change of speed, a change of style...</p>')
.setWidth(250)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My add-on');
我在 Google 脚本编辑器中创建了一个脚本,这样当用户单击 Google 表格中工具栏上的菜单时,它会弹出一个应用程序框,用户可以在其中单击以进行打印。
但是,我不确定如何为出现的那个应用程序框添加自定义尺寸而不会弄乱代码。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below to print using the Google Cloud Print service.');
}
和index.html代码是:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script src="https://www.google.com/cloudprint/client/cpgadget.js">
</script>
<script>
window.onload = function() {
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(
cloudprint.Gadget.createDefaultPrintButton("button"));
var liabilityWaiver = waiver.getAs(MimeType.PDF);
gadget.setPrintDocument("url", "Test Page", "https://drive.google.com/open?id=0B3NraNAa2RhWSldiNklPVGI5OU0");
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
以下是脚本功能的图片说明:
从最后一张图可以看出,问题出在这里,应用程序框太小,无法容纳所有信息,因此将其删除。
-编辑-
在一位用户 Matt 的帮助下,我设法弄清楚了如何创建更大的应用程序框。然而,即使盒子变大,Google 云打印服务所在的 window 大小仍然很小,无论我将外部应用程序盒子做多大。 (参考下图。)
谁能帮忙把内箱做成外箱的全尺寸?或者只是简单地把它变大?
此致。
查看https://developers.google.com/apps-script/reference/base/ui#showmodaldialoguserinterface-title
var htmlOutput = HtmlService
.createHtmlOutput('<p>A change of speed, a change of style...</p>')
.setWidth(250)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My add-on');