user3533434
user3533434

Reputation: 31

make image clickable in google spreadsheet

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?

Upvotes: 3

Views: 20195

Answers (2)

nazikus
nazikus

Reputation: 529

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"))

enter image description here

Upvotes: 2

John
John

Reputation: 916

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.

Upvotes: 6

Related Questions