如何增加 HTML 应用程序 window 的大小?
How to increase the size of HTML application window?
写信询问 我将如何使用脚本增加内部 HTML 应用程序 window 的大小。
我目前正在创建一个 Google Sheet 工作表,我还在 Google Apps 脚本中创建了一个脚本,以便用户可以通过 [=35] 打印工作表=] 云打印。但是,当我点击打印时,实际的云打印应用程序 window 与外部框相比很小 (请参见下图以更好地表达我的意思。)
所以盒子本身是 300 x 500,但里面 window 是那个宽度的一半,因此切断了大部分 window。我只是想知道是否有任何方法可以使内部 window 变大或与外部应用程序框的大小相匹配?下面是我使用的全部代码。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setWidth(300)
.setHeight(500)
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.');
}
和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>
我相信你看到的是显示的框太大了-看看如果你将框大小调整到下面,它会更合适。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setWidth(670)
.setHeight(500)
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.');
}
<!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("print_button_container")); // div id to contain the button
gadget.setPrintDocument("url", "Test Page", "https://www.google.com/landing/cloudprint/testpage.pdf");
gadget.openPrintDialog();
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
index 打印 google 电子表格
<!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("print_button_container")); // div id to contain the button
gadget.setPrintDocument("google.spreadsheet", "Test Page", "SPREADSHEET-ID-GOES-HERE");
gadget.openPrintDialog();
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
写信询问 我将如何使用脚本增加内部 HTML 应用程序 window 的大小。
我目前正在创建一个 Google Sheet 工作表,我还在 Google Apps 脚本中创建了一个脚本,以便用户可以通过 [=35] 打印工作表=] 云打印。但是,当我点击打印时,实际的云打印应用程序 window 与外部框相比很小 (请参见下图以更好地表达我的意思。)
所以盒子本身是 300 x 500,但里面 window 是那个宽度的一半,因此切断了大部分 window。我只是想知道是否有任何方法可以使内部 window 变大或与外部应用程序框的大小相匹配?下面是我使用的全部代码。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setWidth(300)
.setHeight(500)
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.');
}
和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>
我相信你看到的是显示的框太大了-看看如果你将框大小调整到下面,它会更合适。
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Click to print')
.addItem('Print from Google Cloud', 'openDialog')
.addToUi();
}
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
.setWidth(670)
.setHeight(500)
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi()
.showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.');
}
<!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("print_button_container")); // div id to contain the button
gadget.setPrintDocument("url", "Test Page", "https://www.google.com/landing/cloudprint/testpage.pdf");
gadget.openPrintDialog();
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
index 打印 google 电子表格
<!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("print_button_container")); // div id to contain the button
gadget.setPrintDocument("google.spreadsheet", "Test Page", "SPREADSHEET-ID-GOES-HERE");
gadget.openPrintDialog();
}
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>