Monitor click events on bookmarks (Google Apps Script)

202 views Asked by At

Is there a way to monitor click events on bookmarks in google documents with google apps script? I want to get bookmark id when someone selects a bookmark and than run some more code which needs that bookmark id to get processed.

1

There are 1 answers

0
Silko On BEST ANSWER

With Brian Bennett's help I managed to solve this issue with Web Apps. There is a little bit more code to write but it works.

  1. Write a doGet function:

doGet function is called when a user visits your Web App. With doGet function I opened a document with ID given through get parameters and displayed it as html. To get a html of the document I used this function.

  1. Find and display bookmarks:

You can find bookmarks in the html of the document as html tag with id of the bookmark. I changed the css of all this tags so I could see them (change background, height, width or something like that).

  1. listen to click events on bookmarks with jquery or just javascript:

Listen to click events on those tags (bookmakrs) with jquery or javascript. If you use jquery, you need to import a jquery library. When click event happens get the id of the bookmark from the id attribute of the tag.

  1. Use that bookmark id as you wish...