使用HtmlService在站点应用程序脚本中透明背景 [英] Transparent background in Sites Apps Script with HtmlService

查看:86
本文介绍了使用HtmlService在站点应用程序脚本中透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有类似的问题:
Google App脚本背景透明与HtmlService
没有令人满意的答案。



在我的情况下,我在Google协作平台中嵌入了一个简单的Apps脚本:



CODE.GS



 函数doGet(){
return HtmlService.createTemplateFromFile('Page')
.evaluate()。setSandboxMode (HtmlService.SandboxMode.NATIVE);
}

PAGE.HTML

 < HTML> 
< body style =background-color:transparent>
我如何制作< br />透明?
< / body>
< / html>

导致页面如下所示:



https://sites.google.com/site/seanpj01/backtest

即使设定

 < body style = 背景色:透明> 

如果作为直接的XML封装的小工具实现,它会失败(我怀疑CAJA) 。这里有一个关于这个问题的讨论:
http:// productforums .google.com / forum /#!topic / sites / KU9nSz37c6U



但是,无济于事。谢谢

解决方案

不要使用html,head或body标签 b


当您的页面被Caja消毒时,高级结构标记将被
替换为虚拟标记,并且您的标记将被插入由Caja创建的另一个
页面。例如,标签被替换为
。您附加到这些元素的任何样式或脚本都保留了
,但语义含义发生了变化。



由于这种行为,我们建议您不要使用,
或网页中的标签,而是直接在页面中放置
样式,脚本和其他HTML内容。要设置
为页面的标题,请使用HtmlOutput的setTitle()方法,因为页面中的
标签将被忽略。

您可以为您的网站创建小工具 。小工具可以通过http与谷歌应用脚​​本进行交流。


There is a similar question in: Google App Script background transparent with HtmlService with no satisfactory answer.

In my situation, I have this simple Apps Script embedded in Google Sites:

CODE.GS

function doGet() {
  return HtmlService.createTemplateFromFile('Page')
    .evaluate().setSandboxMode(HtmlService.SandboxMode.NATIVE);
}

PAGE.HTML

<html>
  <body style="background-color:transparent">
    How do I make it<br/>transparent ?
  </body>
</html>

resulting in a page that looks like this:

https://sites.google.com/site/seanpj01/backtest

Even if the trick of setting

<body style="background-color:transparent"> 

works if implemented as a straight XML-wrapped gadget, it fails in this situation (I suspect CAJA). There is a discussion on this problem here: http://productforums.google.com/forum/#!topic/sites/KU9nSz37c6U

but again, to no avail. Thanks

解决方案

Don't use html, head, or body tags

When your page is sanitized by Caja, high-level structural tags are replaced with virtual tags and your markup is inserted into another page created by Caja. For example, an tag is replaced by . Any styles or scripts you attach to these elements are preserved, but the semantic meaning changes.

Because of this behavior, we recommend that you don't use , , or tags in your page and instead just place your styles, scripts, and other HTML content directly in the page. To set the title of your page, use the setTitle() method of HtmlOutput, since tags in your page are ignored.

Instead you may create a gadget for your site. Gadgets can communicate to google apps script over http.

这篇关于使用HtmlService在站点应用程序脚本中透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆