我一直在尝试将带有超级链接的图像放入google应用程序的脚本ui中。我最初想到使用createAnchor(),但它只支持文本。然后我想使用一个按钮,但据我所知,你不能打开一个新的标签/窗口并在回调函数中重定向。
我也尝试过createHTML(),但是元素还没有被它处理。
我见过人们将透明按钮覆盖在图像上,但在回调中仍然存在同样的问题。
我的研究还没有找到这个问题的答案。有人有什么解决方案/例子吗?
谢谢
发布于 2012-07-09 11:28:34
这对我在Chrome20和IE9上很有效
// Container for box and results
var imageContainer = app.createFlexTable();
// Setup the button
var button = app.createButton("ImageButton");
button.setStyleAttribute("background", "url(dontshowimagehere.JPG) no-repeat");
button.setStyleAttribute("position", "absolute");
button.setStyleAttribute("color", "transparent");
button.setStyleAttribute('zIndex','1');
button.setStyleAttribute("border", "0px solid black");
imageContainer.setWidget(0, 0, button);
// image to click
var image = app.createImage("image.jpg").setId(imageId);
imageContainer.setWidget(1,0, image); 图像的偏移量很小(3px)。如果重要的话,这看起来可以解决这个问题(对于flex表使用http://www.w3schools.com/css/css_positioning.asp,对于图像和按钮使用top etc )
发布于 2012-11-17 10:19:24
你有没有尝试过覆盖图像的透明锚点?
function doGet() {
var app = UiApp.createApplication().setTitle("Image Anchor");
var panel = app.createAbsolutePanel().setWidth('50%').setHeight('50%');
var image = app.createImage().setUrl("https://lh6.googleusercontent.com/-v0Q3gPQz03Q/T_y5gcVw7LI/AAAAAAAAAF8/ol9uup7Xm2g/s512/GooglePlus-512-Red.png").setStyleAttribute("width", "28px").setStyleAttribute("height", "28px");
var anchor = app.createAnchor("?", "https://plus.google.com/u/1/116085534841818923812/posts").setHeight("28px").setWidth("28px").setStyleAttribute("opacity", "0.1").setTarget("blank");
panel.add(image,100,50);
panel.add(anchor,100,50);
app.add(panel);
return app.close();
}发布于 2013-04-21 19:47:57
app.createAbsolutePanel() .add(app.createImage('https://www.google.com/images/logos/google_logo_41.png')) .add(app.createAnchor('','https://www.google.co.uk/intl/en/about/') .setStyleAttributes({position:‘绝对’,顶部:‘0px’,左侧:‘0px’,宽度:‘201px’,高度:‘47px’,不透明度:‘0’}))
这是一个经过测试的版本。它工作得很好。它不适用于定位图像(作为‘绝对’)。它不适用于.setHorizontalAlignment(UiApp.HorizontalAlignment.CENTER)
https://stackoverflow.com/questions/10793876
复制相似问题