Skip to content

Instantly share code, notes, and snippets.

@fchasen
Created August 20, 2016 17:25
Show Gist options
  • Save fchasen/5eb32ae8c5c0ee5470765a6ef38ff034 to your computer and use it in GitHub Desktop.
Save fchasen/5eb32ae8c5c0ee5470765a6ef38ff034 to your computer and use it in GitHub Desktop.
book.on('renderer:locationChanged', function(locationCfi){
var epubcfi = new EPUBJS.EpubCFI();
var doc = book.renderer.doc;
var mark = document.createElement("a");
// Give the marker an unique id
mark.id = "look-for-me-1234";
// Add the marker
epubcfi.addMarker(locationCfi, doc, marker);
// Counter words from start of document
// Break when you find the marker
// Remove the marker
epubcfi.removeMarker(mark, doc);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment