简体   繁体   English

带有Google应用脚本的Html。

[英]Html with Google apps script.

I just start to play around with Google Html service, but I cant seem to get my project off the ground. 我刚刚开始使用Google Html服务,但我似乎无法让我的项目开始。 I pieced together this code from the Google examples, but I cant get it to work. 我将这些代码从Google示例拼凑在一起,但我无法让它工作。 In a script document i have 2 files one is called Code.gs the other is Map.html. 在脚本文档中我有2个文件,一个叫做Code.gs,另一个是Map.html。 When I publish this script as a web App and then run it the page comes up black. 当我将此脚本作为Web应用程序发布然后运行它时,页面显示为黑色。 I know that it is kinda working because if i insert a 我知道它有点工作,因为如果我插入一个

Hello world 你好,世界

into the body, the web page shows Hello World. 进入正文,网页显示Hello World。 Bellow is the code for Code.gs and Map.html respectively Bellow分别是Code.gs和Map.html的代码

 function doGet() { return HtmlService.createHtmlOutputFromFile('Map'); } 

black 黑色

 <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {'packages': ['geochart']}); google.setOnLoadCallback(drawMarkersMap); function drawMarkersMap() { var data = google.visualization.arrayToDataTable([ ['City', 'Population', 'Area'], ['Rome', 2761477, 1285.31], ['Milan', 1324110, 181.76], ['Naples', 959574, 117.27], ['Turin', 907563, 130.17], ['Palermo', 655875, 158.9], ['Genoa', 607906, 243.60], ['Bologna', 380181, 140.7], ['Florence', 371282, 102.41], ['Fiumicino', 67370, 213.44], ['Anzio', 52192, 43.43], ['Ciampino', 38262, 11] ]); var options = { region: 'IT', displayMode: 'markers', colorAxis: {colors: ['green', 'blue']} }; var chart = new google.visualization.GeoChart(document.getElementById('chart_div')); chart.draw(data, options); }; </script> </head> <body> <div id="chart_div" style="width: 900px; height: 500px;"></div> </body> </html> 

This is because the library you using is not supported by caja. 这是因为caja不支持您使用的库。 Caja is a engine that it will be used to check before it can be displayed to the user and currently, it support JQuery and JQuery UI, https://developers.google.com/apps-script/html_service#Caja . Caja是一个引擎,它可以在用户显示之前用于检查,目前它支持JQuery和JQuery UI, https://developers.google.com/apps-script/html_service#Caja So if you wish to test you code, you might want to go http://caja.appspot.com/ and test it. 因此,如果您希望测试代码,可能需要访问http://caja.appspot.com/并进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM