var panel = app.createSimplePanel();
// add your image to the simple panel or whatever panel you wish to choose in your GUI
var popPanel = app.createSimplePanel()
.setStyleAttribute('top','Y')
.setStyleAttribute('left','X')
.setStyleAttribute('zIndex','1')
.setStyleAttribute('position','fixed');
// add your anchor to the popPanel
app.add(panel).add(popPanel);
var myString = 'the html you want to add, for example you image link and button';
var page = SitesApp.getSite('example.com', 'mysite').getChildByName('targetpage');
var upage = page.setHtmlContent('<div>' + myString + '</div>');
7 回答
这适用于Chrome20和IE9
图像具有轻微(3px)偏移 . 如果重要的话,这看起来要修复它http://www.w3schools.com/css/css_positioning.asp(对图像和按钮使用flex表和顶部等的相对值)
您是否尝试过覆盖图像的透明锚点?
这是经过测试的 . 它工作正常 . 它不适用于定位图像(“绝对”) . 它不适用于.setHorizontalAlignment(UiApp.HorizontalAlignment.CENTER)
我不相信这可用于小部件 . 我建议改变你的UI设计,以便使用Anchor小部件 .
如果您直接在页面上编码,请使用HTML Box . 点击“修改”编辑您的页面,然后转到菜单中的“插入> HTML框” . 它也会接受javascript!有几点需要注意 - 当使用javascript时,HTML Box不会接受链接......太糟糕了,但是有太多的漏洞 .
如果您使用应用程序脚本进行编码,则可以尝试将图像放在面板上并使用绝对面板并将链接放在图像上 . 另一种方法可以是使用.setStyleAttribute进行CSS样式,并利用zIndex参数将面板放在图像顶部....就像这样:
不是100%确定你是否可以使这个面板透明,但你可以尝试类似:.setStyleAttribute('background',transparent')或通过以下方式更改不透明度:.setStyleAttribute('opacity',' . 5')
希望这会给你一些想法!
我设法用一个Anchor对象并使用CSS3 . 它适用于Chrome,我没有在其他浏览器中测试它 .
当然你必须用你的数据替换$ ...... $ .
蒂埃里
如果您首先在字符串中创建所有HTML,则可以使用您想要的HTML替换页面内容: