make image clickable in google spreadsheet

喜夏-厌秋 提交于 2019-12-23 17:04:55

问题


I try to make clickable an imported image into Google spreadsheet. When I click it to take me to another website.

I was able to: - insert the image - to 'Assign script' to it - that looks like this:

function showMessageBox() {
  Browser.msgBox('You clicked it!');
}

When I click the image the above message comes up. However I need a script that I can assign and opens an outside url when image clicked.

Is there such a script available?


回答1:


These are the two solutions I was able to come up with:

(1) Assign this script to your image and replace the link with your own. It requires one more user click, but it's probably the best you can do. Caja locks down everything output by the HTML Service pretty tight, so things like window.location.replace("http://www.example.com"); or window.location.href = "http://www.example.com"; are a no go.

function redirectTest(){
  var htmlOutput = HtmlService
    .createHtmlOutput('<a href="http://www.example.com">Click Me!</a>')
    .setWidth(100)
    .setHeight(100);
 SpreadsheetApp.getUi().showModelessDialog(htmlOutput, " ");
}

(2) According to this source and this source, the following formula should work:

=HYPERLINK("http://www.example.com", IMAGE("https://www.google.com/images/srpr/logo11w.png"))

I couldn't get it to work in my tests, but the sources aren't that old.




回答2:


You can achieve clickable images with formulas alone. But clickable link appears only after cell selection, not sure if its acceptable in your case.

=HYPERLINK("http://www.artchive.com/artchive/d/durer/durer_mill.jpg", image("http://www.artchive.com/artchive/d/durer/durer_mill.jpg"))



来源:https://stackoverflow.com/questions/23176203/make-image-clickable-in-google-spreadsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!