I want to write a script which detects the mouse hovering over a cell (or if not possible, triggered by a menu as described in "Google Developers: Apps Script: Custom Menus in Google Apps".

This script would display a popup, or fill a special cell with an image. This image URL would be built using the content of the cell.

Any idea?

  • Have you made some progress in the meantime? Feb 9, 2013 at 23:01
  • 2
    Hovering is definitely a non-starter; one cannot directly interact with DOM of a Google service page from within a Spreadsheet or Apps script environment.
    – user79865
    Jul 24, 2015 at 18:10

2 Answers 2


Short answer

Use 1) the HTML Service of Google Apps Script or 2) update a cell formula with the IMAGE() fuction, any of them triggered by a Custom Menu as Google Docs editors doesn't include a mouse hovering event.


Google spreadsheets and Google Apps Script (GAS) have had a lot of changes since the question was posted. One of them is that the GAS documentation was moved to http://developers.google.com/apps-script.

AFAIK GAS doesn't have a mouse hovering trigger event but there are several alternatives like custom menus, simple triggers and installable triggers.

By the other side, filling a cell with an image can be done with a built-in function, IMAGE(), which have four image sizing modes.

GAS an IMAGE() could be used together to insert an image inside a cell and this could be triggered by a custom menu.


Use Custom Menus instead of mouse hovering to trigger one of the next actions:

  1. Update a cell formula with the IMAGE() function.
  2. Use a method of the UI Class like:

    1. showModalDialog
    2. showSideBar

In both cases the image should be part of an htmlOutput object of the HTML Service.


About Notes and Comments

Built-in notes or comments are displayed by mouse hovering. They could include the image URL. Notes will display it as text while a comment as a link.

Once the user is in the Google Sheets spreadsheet editor.

  • To insert a note click Insert > Note
  • To insert a comment click Insert > Comment

About other UI resources

  • toast, alert and prompt Google Apps Script methods shows plain text messages.

HTML Service: Restrictions

From [3]:

To protect users from being served malicious HTML or JavaScript, Apps Script uses a security sandbox to sandbox HTML-service web apps or custom user interfaces for Google Docs, Sheets, and Forms. (The HTML service does not use a sandbox in other situations, like generating the body of an email.) The sandbox imposes limitations on client-side code.


  • 1
    This IMAGE function is really part of what I wanted, thanks ! Jul 24, 2015 at 16:32
  • Any idea how I can launch a javascript when I click or hover over a cell ? And display the image over the cells rather than in a cell (which has quite small height) ? Jul 24, 2015 at 16:33
  • 1
    Google Apps Script is the Google version of JavaScript to extend several Google Apps. Unfortunately it doesn't include mouse hovering or mouse gestures to trigger custom functions. The possibilities to extend Google Apps are limited due to security concerns. For further details see developers.google.com/apps-script/guides/html/restrictions Jul 24, 2015 at 16:40
  • Forget to mention @MichelDaviot Jul 24, 2015 at 16:46
  • 1
    @MichelDaviot I updated the question. Hopefully now is more clear and helpful. Jul 25, 2015 at 20:02

Why don't you use Hover Zoom extension for chrome? You won't need to do anything, just hover over the image link and you will get a pop-up with the image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.